{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "e8ff29a0",
   "metadata": {},
   "source": [
    "# 基于backtrader多因子策略框架的优化"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "c03a50fa",
   "metadata": {},
   "outputs": [],
   "source": [
    "import sqlite3\n",
    "import pandas as pd  \n",
    "import talib\n",
    "from datetime import datetime\n",
    "import backtrader as bt\n",
    "import matplotlib.pyplot as plt\n",
    "import akshare as ak\n",
    "import numpy as np\n",
    "%matplotlib inline   \n",
    "\n",
    "#正常显示画图时出现的中文和负号\n",
    "from pylab import mpl\n",
    "\n",
    "mpl.rcParams['font.sans-serif']=['SimHei']\n",
    "mpl.rcParams['axes.unicode_minus']=False"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 88,
   "id": "d28df25b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'1.20.0'"
      ]
     },
     "execution_count": 88,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import streamlit as st\n",
    "\n",
    "st.__version__"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "407b39a3",
   "metadata": {},
   "source": [
    "## 多因子交易策略框架\n",
    "\n",
    "### 通用多股策略"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "285670b3",
   "metadata": {},
   "outputs": [],
   "source": [
    "conn=sqlite3.connect(r'F:\\量化金融\\stock_2018.db')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "e9a01765",
   "metadata": {},
   "outputs": [],
   "source": [
    "stock_daily=pd.read_sql(\"select * from stock_daily where 股票代码>'003000.SZ'\",con=conn)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "f3d99d73",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['index', '交易日期', '股票代码', '股票简称', '开盘价', '最高价', '最低价', '收盘价', '成交量(手)',\n",
       "       '成交额(千元)', '换手率(%)', '量比', '市盈率(静态)', '市盈率(TTM)', '市盈率(动态)', '市净率',\n",
       "       '市销率', '市销率(TTM)', '股息率(%)', '股息率(TTM)(%)', '总股本(万股)', '流通股本(万股)',\n",
       "       '总市值(万元)', '流通市值(万元)'],\n",
       "      dtype='object')"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stock_daily.columns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "923f2263",
   "metadata": {},
   "outputs": [],
   "source": [
    "stock_daily.columns=['index', 'date', '股票代码', '股票简称', 'open', 'high', 'low', 'close', 'volume',\n",
    "       '成交额(千元)', '换手率(%)', '量比', '市盈率(静态)', '市盈率(TTM)', '市盈率(动态)', '市净率',\n",
    "       '市销率', '市销率(TTM)', '股息率(%)', '股息率(TTM)(%)', '总股本(万股)', '流通股本(万股)',\n",
    "       '总市值(万元)', '流通市值(万元)']\n",
    "stock_daily[\"date\"]=stock_daily[\"date\"].astype(\"str\").astype(\"datetime64\")\n",
    "stock_daily.set_index(\"date\",inplace=True,drop=False)\n",
    "stock_daily[\"openinterest\"]=0\n",
    "n1=len(stock_daily.date.unique())\n",
    "z1=pd.Series(range(0,n1),index=stock_daily.date.unique()).sort_index()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "5ac87fd1",
   "metadata": {},
   "outputs": [],
   "source": [
    "def get_data_1(syboml):\n",
    "    stock=stock_daily[stock_daily[\"股票代码\"]==syboml][[\"open\",\"high\",\"low\",\"close\",\"volume\",\"openinterest\"]]\n",
    "    stock=pd.concat([stock,z1],axis=1).fillna(method=\"bfill\").fillna(method=\"ffill\")\n",
    "    return stock[[\"open\",\"high\",\"low\",\"close\",\"volume\",\"openinterest\"]]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "715c1c2d",
   "metadata": {},
   "outputs": [],
   "source": [
    "class my_strategy_date_2(bt.Strategy):\n",
    "    #全局设定交易策略的参数\n",
    "\n",
    "    def __init__(self):\n",
    "        # 初始化交易指令、买卖价格和手续费\n",
    "        self.order = None\n",
    "\n",
    "    def next(self):\n",
    "        # 检查是否持仓 \n",
    "        #print(str(self.datetime.date(0)))\n",
    "        cash_value.update({str(self.datetime.date(0)):self.broker.getvalue()})\n",
    "        if str(self.datetime.date(0)) in sell_date.keys(): # 没有持仓\n",
    "            s_list=sell_date[str(self.datetime.date(0))]\n",
    "            for i in s_list:\n",
    "                self.order_target_percent(target=0,data=i)\n",
    "        if str(self.datetime.date(0)) in buy_date.keys(): # 没有持仓\n",
    "            s_list=buy_date[str(self.datetime.date(0))]\n",
    "            for i in s_list:\n",
    "                self.order_target_percent(target=0.9/len(s_list),data=i)\n",
    "                \n",
    "\n",
    "            \n",
    "    def log(self, txt, dt=None):\n",
    "        ''' 输出日志'''\n",
    "        dt = dt or self.datas[0].datetime.date(0) # 拿现在的日期\n",
    "        print('%s, %s' % (dt.isoformat(), txt))\n",
    "\n",
    "    def notify_order(self, order):\n",
    "        if order.status in [order.Submitted, order.Accepted]:\n",
    "            # Buy/Sell order submitted/accepted to/by broker - Nothing to do\n",
    "            return\n",
    "\n",
    "        # Check if an order has been completed\n",
    "        # Attention: broker could reject order if not enough cash\n",
    "        if order.status in [order.Completed, order.Canceled, order.Margin]:\n",
    "            if order.isbuy():\n",
    "                self.log(f\"\"\"买入{order.data._name}, 成交量{order.executed.size}，成交价{order.executed.price:.2f}\"\"\")\n",
    "            elif order.issell():\n",
    "                self.log(f\"\"\"卖出{order.data._name}, 成交量{order.executed.size}，成交价{order.executed.price:.2f}\"\"\")\n",
    "            self.bar_executed = len(self)\n",
    "\n",
    "        # Write down: no pending order\n",
    "        self.order = None\n",
    "\n",
    "#这是读入一个股票数据的策略，请改写为多个股票读入\n",
    "def huice_run_num(start,end,stock_list,strategy):\n",
    "\n",
    "    cerebro = bt.Cerebro()\n",
    "    for i in stock_list:\n",
    "        stock=get_data_1(i)\n",
    "        data = bt.feeds.PandasData(dataname=stock,fromdate=start,todate=end)           \n",
    "        cerebro.adddata(data,name=i) \n",
    "        \n",
    "    cerebro.addstrategy(strategy) \n",
    "    cerebro.broker.setcash(100000) \n",
    "    cerebro.broker.setcommission(commission=0.002) \n",
    "\n",
    "\n",
    "    print(start.date(),end.date())\n",
    "    print('初始资金: %.2f' % cerebro.broker.getvalue())\n",
    "    cerebro.addanalyzer(bt.analyzers.SharpeRatio, _name = 'SharpeRatio')\n",
    "    cerebro.addanalyzer(bt.analyzers.DrawDown, _name='DW')\n",
    "    results = cerebro.run()\n",
    "    strat = results[0]\n",
    "    print('最终资金: %.2f' % cerebro.broker.getvalue())\n",
    "    print('夏普比率:', strat.analyzers.SharpeRatio.get_analysis())\n",
    "    print('回撤指标:', strat.analyzers.DW.get_analysis())\n",
    "    \n",
    "    return cerebro"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "9f09ecff",
   "metadata": {},
   "outputs": [],
   "source": [
    "start=datetime(2018,2,22)\n",
    "end=datetime(2023,2,10)\n",
    "stock_list=[\"003002.SZ\",\"003003.SZ\",\"300001.SZ\"]\n",
    "buy_date={\"2020-09-22\":[\"003002.SZ\",\"003003.SZ\"]}\n",
    "sell_date={\"2023-02-02\":[\"003002.SZ\",\"003003.SZ\"]}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "6db2457a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2018-02-22 2023-02-10\n",
      "初始资金: 100000.00\n",
      "2020-09-23, 买入003002.SZ, 成交量3800，成交价13.02\n",
      "2020-09-23, 买入003003.SZ, 成交量2707，成交价18.28\n",
      "2023-02-03, 卖出003002.SZ, 成交量-3800，成交价20.89\n",
      "2023-02-03, 卖出003003.SZ, 成交量-2707，成交价12.09\n",
      "最终资金: 112731.75\n",
      "夏普比率: OrderedDict([('sharperatio', 0.13880099293497766)])\n",
      "回撤指标: AutoOrderedDict([('len', 58), ('drawdown', 8.111117263713433), ('moneydown', 9950.936514), ('max', AutoOrderedDict([('len', 455), ('drawdown', 47.599755296618), ('moneydown', 56371.585799999986)]))])\n"
     ]
    }
   ],
   "source": [
    "cash_value={}\n",
    "result=huice_run_num(start,end,stock_list,my_strategy_date_2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "id": "342bd97a",
   "metadata": {},
   "outputs": [],
   "source": [
    "cash_value=pd.Series(cash_value)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "id": "c0d75ebd",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<AxesSubplot:>"
      ]
     },
     "execution_count": 49,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAABB8AAAFjCAYAAAB14KO1AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAAsTAAALEwEAmpwYAABsl0lEQVR4nO3dd3Sb1eHG8e+VvPfedhxn7+WEBBIIEEYKtEApqwVKB6XQ/Wvp3qWDLihtaRmFltKW0RbKhhBGQhbZZMdJvOO9LduypPf3hxwlju3ETizLsZ/POT6R7rvuq9wjW4/uMJZlISIiIiIiIiLiL7ZAV0BERERERERERjaFDyIiIiIiIiLiVwofRERERERERMSvFD6IiIiIiIiIiF8pfBARERERERERv1L4ICIiIiIiIiJ+FRToCgxUUlKSlZubG+hqiIiIiIiIiMhxNm3aVGNZVvLx5Wdc+JCbm8vGjRsDXQ0REREREREROY4xpqi3cg27EBERERERERG/UvggIiIiIiIiIn6l8EFERERERERE/Erhg4iIiIiIiIj4lcIHEREREREREfErhQ8iIiIiIiIi4lcKH0RERERERETErxQ+iIiIiIiIiIhfKXwQEREREREREb9S+CAiIiIiIiIifqXwQURERERERET8SuGDiIiIiIiIyDCys7yRvRXNga7GoDph+GCMiTfGvGSM2WiM+XNX2SPGmLXGmO8cs9+glom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vX8NUf9pWH+8z/W0fve13yu95A7iuDAOn0b76q7f20N/3n8FumzKETrVtDaC99dY++vt30+m0SxkGTqN9fd0Yc3PXfnFAQx+XOJ33wsF+H/UPy7JG/Q/wWbxdYN7q+rkF2Ib3j/LdQOwx+751zOMFwE6837i8DkT1cf6Y48/XyzWv62fdruvvsfoZHj/+bl99HDugNnLssf0p18/w+DnVttX1/IfATf28zrFtq8f72QCOjcb7S/AdvOMdMwP9Gurn1NtWH7+f+tU++vi9eDrveQNql/o5M9tXb//3A2hf/Xr/GYy2qZ8zr22dqL2drH0ct73Ptnk67VI/w+PnNNpXfNd7xzvAHwEzgDZyym2zv8cO5Y/pqqwcx3hnVL4IeMeyrNOedG+wzydnNrUH8ZehaFtqv6NTf//fB3u/wa6fDE/DqT2oLY0salviT2pfA6PwQURERERERET8SnM+iIiIiIiIiIhfKXwQEREREREREb9S+CAiIiIiIiIifqXwQURERERERET8SuGDiIiIiIiIiPjV/wPtrtuq1ABtyAAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 1296x432 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "cash_value.plot(figsize=(18,6))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9a3f9fff",
   "metadata": {},
   "source": [
    "### 基于排序的多因子交易方案的构建函数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "53da3174",
   "metadata": {},
   "outputs": [],
   "source": [
    "time_id=pd.Series(stock_daily.date.unique()).sort_values().tolist()[::30]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 79,
   "id": "c091d950",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Timestamp('2020-06-23 00:00:00')"
      ]
     },
     "execution_count": 79,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time_id[20]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "e4322aa2",
   "metadata": {},
   "outputs": [],
   "source": [
    "buy_date={}\n",
    "sell_date={}\n",
    "postion=set([])\n",
    "stock_list=set([])\n",
    "for i in time_id:\n",
    "    \n",
    "    factor1_stock=stock_daily[stock_daily[\"date\"]==i].sort_values(by='换手率(%)',ascending=True)[\"股票代码\"].tolist()\n",
    "    factor2_stock=stock_daily[stock_daily[\"date\"]==i].sort_values(by='volume',ascending=True)[\"股票代码\"].tolist()\n",
    "    f_1_df=pd.Series(range(1,len(factor1_stock)+1),index=factor1_stock)\n",
    "    f_2_df=pd.Series(range(1,len(factor2_stock)+1),index=factor2_stock)\n",
    "    f_1_2=pd.concat([f_1_df,f_2_df],axis=1)\n",
    "    f_1_2[2]=f_1_2[0]+f_1_2[1]\n",
    "    \n",
    "    buy_list=f_1_2.sort_values(by=2).head(5).index.tolist()\n",
    "    buy_date.update({str(i.date()):buy_list})\n",
    "    sell_date.update({str(i.date()):list(postion-set(buy_list))})\n",
    "    postion=set(buy_list)\n",
    "    stock_list=stock_list|postion"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "9c05c4fa",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2018-02-22 2023-02-10\n",
      "初始资金: 100000.00\n",
      "2018-04-04, 买入300504.SZ, 成交量790，成交价25.04\n",
      "2018-04-04, 买入300634.SZ, 成交量895，成交价22.12\n",
      "2018-04-04, 买入300125.SZ, 成交量349，成交价51.52\n",
      "2018-04-04, 买入300042.SZ, 成交量339，成交价52.58\n",
      "2018-04-04, 买入300180.SZ, 成交量306，成交价59.40\n",
      "2018-05-22, 卖出300042.SZ, 成交量-339，成交价49.72\n",
      "2018-05-22, 卖出300125.SZ, 成交量-349，成交价59.63\n",
      "2018-05-22, 卖出300504.SZ, 成交量-790，成交价55.00\n",
      "2018-05-22, 卖出300634.SZ, 成交量-895，成交价60.19\n",
      "2018-05-22, 买入300454.SZ, 成交量488，成交价63.39\n",
      "2018-05-22, 买入300180.SZ, 成交量167，成交价59.66\n",
      "2018-05-22, 买入300416.SZ, 成交量556，成交价50.97\n",
      "2018-05-22, 买入300057.SZ, 成交量1589，成交价17.90\n",
      "2018-05-22, 买入300342.SZ, 成交量496，成交价57.06\n",
      "2018-07-04, 卖出300454.SZ, 成交量-488，成交价114.88\n",
      "2018-07-04, 卖出300342.SZ, 成交量-496，成交价51.29\n",
      "2018-07-04, 卖出300057.SZ, 成交量-1589，成交价13.03\n",
      "2018-07-04, 卖出300180.SZ, 成交量-473，成交价50.88\n",
      "2018-07-04, 卖出300416.SZ, 成交量-556，成交价40.74\n",
      "2018-07-04, 买入300747.SZ, 成交量304，成交价106.96\n",
      "2018-07-04, 买入300028.SZ, 成交量6601，成交价4.03\n",
      "2018-07-04, 买入300266.SZ, 成交量143，成交价185.49\n",
      "2018-07-04, 买入300090.SZ, 成交量603，成交价44.21\n",
      "2018-07-04, 买入300317.SZ, 成交量1002，成交价26.61\n",
      "2018-08-15, 卖出300747.SZ, 成交量-304，成交价154.50\n",
      "2018-08-15, 卖出300266.SZ, 成交量-143，成交价75.83\n",
      "2018-08-15, 卖出300317.SZ, 成交量-1002，成交价17.82\n",
      "2018-08-15, 卖出300028.SZ, 成交量-6601，成交价1.67\n",
      "2018-08-15, 卖出300090.SZ, 成交量-603，成交价22.87\n",
      "2018-08-15, 买入300724.SZ, 成交量906，成交价27.14\n",
      "2018-08-15, 买入300125.SZ, 成交量444，成交价50.33\n",
      "2018-08-15, 买入300518.SZ, 成交量493，成交价45.16\n",
      "2018-08-15, 买入300243.SZ, 成交量572，成交价39.22\n",
      "2018-08-15, 买入300087.SZ, 成交量277，成交价81.28\n",
      "2018-09-27, 卖出300125.SZ, 成交量-444，成交价46.51\n",
      "2018-09-27, 卖出300724.SZ, 成交量-906，成交价26.30\n",
      "2018-09-27, 卖出300243.SZ, 成交量-572，成交价39.97\n",
      "2018-09-27, 卖出300087.SZ, 成交量-277，成交价82.66\n",
      "2018-09-27, 买入300749.SZ, 成交量1152，成交价21.30\n",
      "2018-09-27, 买入300748.SZ, 成交量2376，成交价10.33\n",
      "2018-09-27, 卖出300518.SZ, 成交量-31，成交价48.35\n",
      "2018-09-27, 买入300416.SZ, 成交量566，成交价39.37\n",
      "2018-09-27, 买入300042.SZ, 成交量439，成交价51.02\n",
      "2018-11-15, 卖出300518.SZ, 成交量-462，成交价28.71\n",
      "2018-11-15, 卖出300042.SZ, 成交量-439，成交价31.11\n",
      "2018-11-15, 卖出300749.SZ, 成交量-1152，成交价27.52\n",
      "2018-11-15, 卖出300748.SZ, 成交量-2376，成交价28.45\n",
      "2018-11-15, 卖出300416.SZ, 成交量-566，成交价38.21\n",
      "2018-11-15, 买入300674.SZ, 成交量1467，成交价21.32\n",
      "2018-11-15, 买入300751.SZ, 成交量261，成交价119.50\n",
      "2018-11-15, 买入300572.SZ, 成交量348，成交价81.56\n",
      "2018-11-15, 买入300018.SZ, 成交量891，成交价35.06\n",
      "2018-11-15, 买入300280.SZ, 成交量882，成交价32.22\n",
      "2018-12-27, 卖出300572.SZ, 成交量-348，成交价78.56\n",
      "2018-12-27, 卖出300751.SZ, 成交量-261，成交价117.94\n",
      "2018-12-27, 卖出300674.SZ, 成交量-1467，成交价31.71\n",
      "2018-12-27, 卖出300018.SZ, 成交量-891，成交价32.09\n",
      "2018-12-27, 买入300233.SZ, 成交量1054，成交价28.57\n",
      "2018-12-27, 买入300280.SZ, 成交量43，成交价32.19\n",
      "2018-12-27, 买入300475.SZ, 成交量3493，成交价8.64\n",
      "2018-12-27, 买入300206.SZ, 成交量812，成交价37.32\n",
      "2018-12-27, 买入300516.SZ, 成交量1051，成交价28.72\n",
      "2019-02-18, 卖出300233.SZ, 成交量-1054，成交价31.68\n",
      "2019-02-18, 卖出300206.SZ, 成交量-812，成交价39.00\n",
      "2019-02-18, 卖出300516.SZ, 成交量-1051，成交价30.15\n",
      "2019-02-18, 卖出300475.SZ, 成交量-3493，成交价8.78\n",
      "2019-02-18, 买入300483.SZ, 成交量1004，成交价31.06\n",
      "2019-02-18, 买入300176.SZ, 成交量177，成交价176.47\n",
      "2019-02-18, 卖出300280.SZ, 成交量-14，成交价34.31\n",
      "2019-02-18, 买入300204.SZ, 成交量390，成交价80.10\n",
      "2019-02-18, 买入300573.SZ, 成交量1859，成交价16.91\n",
      "2019-04-01, 卖出300280.SZ, 成交量-911，成交价31.17\n",
      "2019-04-01, 卖出300483.SZ, 成交量-1004，成交价34.94\n",
      "2019-04-01, 卖出300204.SZ, 成交量-390，成交价109.65\n",
      "2019-04-01, 卖出300176.SZ, 成交量-177，成交价215.51\n",
      "2019-04-01, 卖出300573.SZ, 成交量-1859，成交价19.50\n",
      "2019-04-01, 买入300767.SZ, 成交量1284，成交价30.39\n",
      "2019-04-01, 买入300766.SZ, 成交量1286，成交价30.34\n",
      "2019-04-01, 买入300473.SZ, 成交量901，成交价39.59\n",
      "2019-04-01, 买入300762.SZ, 成交量530，成交价73.58\n",
      "2019-04-01, 买入300616.SZ, 成交量222，成交价161.09\n",
      "2019-05-17, 卖出300762.SZ, 成交量-530，成交价60.36\n",
      "2019-05-17, 卖出300766.SZ, 成交量-1286，成交价53.22\n",
      "2019-05-17, 卖出300767.SZ, 成交量-1284，成交价39.44\n",
      "2019-05-17, 买入300777.SZ, 成交量4606，成交价9.60\n",
      "2019-05-17, 买入300616.SZ, 成交量39，成交价152.50\n",
      "2019-05-17, 买入300286.SZ, 成交量601，成交价66.85\n",
      "2019-05-17, 买入300473.SZ, 成交量345，成交价32.28\n",
      "2019-05-17, 买入300436.SZ, 成交量767，成交价52.42\n",
      "2019-07-01, 卖出300436.SZ, 成交量-767，成交价52.95\n",
      "2019-07-01, 卖出300286.SZ, 成交量-601，成交价63.95\n",
      "2019-07-01, 卖出300473.SZ, 成交量-1246，成交价30.47\n",
      "2019-07-01, 卖出300777.SZ, 成交量-4606，成交价37.22\n",
      "2019-07-01, 买入300454.SZ, 成交量695，成交价89.52\n",
      "2019-07-01, 买入300616.SZ, 成交量181，成交价141.02\n",
      "2019-07-01, 买入300530.SZ, 成交量1556，成交价39.57\n",
      "2019-07-01, 买入300305.SZ, 成交量1666，成交价36.69\n",
      "2019-07-01, 买入300381.SZ, 成交量1083，成交价56.98\n",
      "2019-08-12, 卖出300305.SZ, 成交量-1666，成交价32.30\n",
      "2019-08-12, 卖出300616.SZ, 成交量-442，成交价142.12\n",
      "2019-08-12, 卖出300530.SZ, 成交量-1556，成交价45.17\n",
      "2019-08-12, 卖出300381.SZ, 成交量-1083，成交价63.48\n",
      "2019-08-12, 买入300473.SZ, 成交量2297，成交价27.64\n",
      "2019-08-12, 买入300233.SZ, 成交量1581，成交价40.75\n",
      "2019-08-12, 买入300440.SZ, 成交量2212，成交价28.81\n",
      "2019-08-12, 买入300258.SZ, 成交量1336，成交价45.58\n",
      "2019-08-12, 卖出300454.SZ, 成交量-25，成交价94.89\n",
      "2019-09-24, 卖出300258.SZ, 成交量-1336，成交价51.66\n",
      "2019-09-24, 卖出300233.SZ, 成交量-1581，成交价45.49\n",
      "2019-09-24, 卖出300454.SZ, 成交量-670，成交价116.65\n",
      "2019-09-24, 卖出300440.SZ, 成交量-2212，成交价29.97\n",
      "2019-09-24, 卖出300473.SZ, 成交量-2297，成交价36.76\n",
      "2019-09-24, 买入300790.SZ, 成交量2552，成交价31.65\n",
      "2019-09-24, 买入300305.SZ, 成交量2218，成交价33.49\n",
      "2019-09-24, 买入300087.SZ, 成交量1134，成交价64.97\n",
      "2019-09-24, 买入300439.SZ, 成交量1650，成交价44.50\n",
      "2019-09-24, 买入300321.SZ, 成交量2280，成交价32.26\n",
      "2019-11-12, 卖出300790.SZ, 成交量-2552，成交价51.20\n",
      "2019-11-12, 卖出300439.SZ, 成交量-1650，成交价42.54\n",
      "2019-11-12, 卖出300321.SZ, 成交量-2280，成交价32.41\n",
      "2019-11-12, 卖出300087.SZ, 成交量-1134，成交价64.81\n",
      "2019-11-12, 买入300564.SZ, 成交量2273，成交价39.53\n",
      "2019-11-12, 买入300305.SZ, 成交量273，成交价32.76\n",
      "2019-11-12, 买入300268.SZ, 成交量2671，成交价30.59\n",
      "2019-11-12, 买入300461.SZ, 成交量2607，成交价31.34\n",
      "2019-11-12, 买入300387.SZ, 成交量2152，成交价38.20\n",
      "2019-12-24, 卖出300564.SZ, 成交量-2273，成交价36.14\n",
      "2019-12-24, 卖出300268.SZ, 成交量-2671，成交价26.45\n",
      "2019-12-24, 卖出300461.SZ, 成交量-2607，成交价40.16\n",
      "2019-12-24, 卖出300387.SZ, 成交量-2152，成交价39.13\n",
      "2019-12-24, 买入300807.SZ, 成交量2653，成交价33.89\n",
      "2019-12-24, 买入300305.SZ, 成交量81，成交价32.15\n",
      "2019-12-24, 买入300233.SZ, 成交量1936，成交价42.33\n",
      "2019-12-24, 买入300526.SZ, 成交量777，成交价106.42\n",
      "2019-12-24, 买入300243.SZ, 成交量2523，成交价32.44\n",
      "2020-02-13, 卖出300233.SZ, 成交量-1936，成交价42.46\n",
      "2020-02-13, 卖出300807.SZ, 成交量-2653，成交价46.20\n",
      "2020-02-13, 卖出300305.SZ, 成交量-2572，成交价30.28\n",
      "2020-02-13, 卖出300243.SZ, 成交量-2523，成交价29.73\n",
      "2020-02-13, 买入300816.SZ, 成交量2509，成交价38.86\n",
      "2020-02-13, 买入300818.SZ, 成交量2912，成交价33.48\n",
      "2020-02-13, 卖出300526.SZ, 成交量-67，成交价125.67\n",
      "2020-02-13, 买入300724.SZ, 成交量1338，成交价72.85\n",
      "2020-02-13, 买入300530.SZ, 成交量1953，成交价45.23\n",
      "2020-03-26, 卖出300818.SZ, 成交量-2912，成交价33.95\n",
      "2020-03-26, 卖出300724.SZ, 成交量-1338，成交价52.40\n",
      "2020-03-26, 卖出300816.SZ, 成交量-2509，成交价39.15\n",
      "2020-03-26, 卖出300530.SZ, 成交量-1953，成交价62.82\n",
      "2020-03-26, 买入300823.SZ, 成交量3020，成交价38.47\n",
      "2020-03-26, 卖出300526.SZ, 成交量-285，成交价272.29\n",
      "2020-03-26, 买入300483.SZ, 成交量3191，成交价32.91\n",
      "2020-03-26, 买入300616.SZ, 成交量868，成交价119.87\n",
      "2020-03-26, 买入300553.SZ, 成交量2914，成交价36.29\n",
      "2020-05-13, 卖出300823.SZ, 成交量-3020，成交价36.97\n",
      "2020-05-13, 卖出300616.SZ, 成交量-868，成交价117.28\n",
      "2020-05-13, 卖出300483.SZ, 成交量-3191，成交价32.04\n",
      "2020-05-13, 卖出300526.SZ, 成交量-425，成交价214.23\n",
      "2020-05-13, 买入300831.SZ, 成交量12999，成交价8.38\n",
      "2020-05-13, 买入300832.SZ, 成交量2191，成交价49.72\n",
      "2020-05-13, 买入300442.SZ, 成交量6336，成交价15.63\n",
      "2020-05-13, 卖出300553.SZ, 成交量-2，成交价34.19\n",
      "2020-05-13, 买入300830.SZ, 成交量10674，成交价10.21\n",
      "2020-06-24, 卖出300831.SZ, 成交量-12999，成交价22.88\n",
      "2020-06-24, 卖出300830.SZ, 成交量-10674，成交价16.03\n",
      "2020-06-24, 卖出300553.SZ, 成交量-2912，成交价35.55\n",
      "2020-06-24, 卖出300832.SZ, 成交量-2191，成交价168.00\n",
      "2020-06-24, 卖出300442.SZ, 成交量-6336，成交价18.52\n",
      "2020-06-24, 买入300824.SZ, 成交量19042，成交价11.33\n",
      "2020-06-24, 买入300028.SZ, 成交量162567，成交价1.09\n",
      "2020-06-24, 买入300842.SZ, 成交量6411，成交价33.65\n",
      "2020-06-24, 买入300841.SZ, 成交量1201，成交价179.52\n",
      "2020-06-24, 买入300286.SZ, 成交量2747，成交价71.99\n",
      "2020-08-07, 卖出300841.SZ, 成交量-1201，成交价800.00\n",
      "2020-08-07, 卖出300842.SZ, 成交量-6411，成交价85.65\n",
      "2020-08-07, 卖出300286.SZ, 成交量-2747，成交价94.71\n",
      "2020-08-07, 卖出300028.SZ, 成交量-162567，成交价0.75\n",
      "2020-08-07, 卖出300824.SZ, 成交量-19042，成交价32.60\n",
      "2020-08-07, 买入300216.SZ, 成交量28295，成交价14.88\n",
      "2020-08-07, 买入300857.SZ, 成交量16304，成交价31.57\n",
      "2020-08-07, 买入300855.SZ, 成交量11928，成交价43.15\n",
      "2020-08-07, 买入300859.SZ, 成交量45212，成交价11.39\n",
      "2020-08-07, 买入300858.SZ, 成交量6396，成交价80.48\n",
      "2020-09-18, 卖出300857.SZ, 成交量-16304，成交价36.53\n",
      "2020-09-18, 卖出300859.SZ, 成交量-45212，成交价39.40\n",
      "2020-09-18, 卖出300216.SZ, 成交量-28295，成交价0.91\n",
      "2020-09-18, 卖出300855.SZ, 成交量-11928，成交价42.50\n",
      "2020-09-18, 卖出300858.SZ, 成交量-6396，成交价72.40\n",
      "2020-09-18, 买入300486.SZ, 成交量21932，成交价28.80\n",
      "2020-09-18, 买入300550.SZ, 成交量13710，成交价46.43\n",
      "2020-09-18, 买入300470.SZ, 成交量3902，成交价162.94\n",
      "2020-09-18, 买入300761.SZ, 成交量15873，成交价40.24\n",
      "2020-09-18, 买入300530.SZ, 成交量6097，成交价103.40\n",
      "2020-11-09, 卖出300470.SZ, 成交量-3902，成交价165.51\n",
      "2020-11-09, 卖出300761.SZ, 成交量-15873，成交价37.20\n",
      "2020-11-09, 买入300530.SZ, 成交量294，成交价90.86\n",
      "2020-11-09, 买入300483.SZ, 成交量15847，成交价36.66\n",
      "2020-11-09, 卖出300550.SZ, 成交量-670，成交价44.54\n",
      "2020-11-09, 买入300683.SZ, 成交量11905，成交价48.81\n",
      "2020-11-09, 买入300486.SZ, 成交量984，成交价25.25\n",
      "2020-12-21, 卖出300483.SZ, 成交量-15847，成交价38.55\n",
      "2020-12-21, 卖出300486.SZ, 成交量-22916，成交价23.07\n",
      "2020-12-21, 卖出300530.SZ, 成交量-6391，成交价82.30\n",
      "2020-12-21, 卖出300683.SZ, 成交量-11905，成交价43.49\n",
      "2020-12-21, 买入300695.SZ, 成交量8275，成交价64.86\n",
      "2020-12-21, 买入003026.SZ, 成交量26831，成交价22.00\n",
      "2020-12-21, 买入300550.SZ, 成交量1133，成交价37.66\n",
      "2020-12-21, 买入003025.SZ, 成交量10843，成交价54.44\n",
      "2020-12-21, 买入300649.SZ, 成交量16083，成交价33.45\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2021-02-02, 卖出003026.SZ, 成交量-26831，成交价86.00\n",
      "2021-02-02, 卖出300550.SZ, 成交量-14173，成交价37.56\n",
      "2021-02-02, 卖出003025.SZ, 成交量-10843，成交价32.70\n",
      "2021-02-02, 买入300695.SZ, 成交量4373，成交价62.90\n",
      "2021-02-02, 买入003036.SZ, 成交量79814，成交价10.97\n",
      "2021-02-02, 买入300321.SZ, 成交量22283，成交价36.20\n",
      "2021-02-02, 买入300069.SZ, 成交量30159，成交价26.16\n",
      "2021-02-02, 买入300649.SZ, 成交量14874，成交价25.62\n",
      "2021-03-23, 卖出300321.SZ, 成交量-22283，成交价38.38\n",
      "2021-03-23, 卖出300649.SZ, 成交量-30957，成交价30.42\n",
      "2021-03-23, 卖出300069.SZ, 成交量-30159，成交价28.56\n",
      "2021-03-23, 卖出003036.SZ, 成交量-79814，成交价12.45\n",
      "2021-03-23, 买入300550.SZ, 成交量25714，成交价33.58\n",
      "2021-03-23, 买入300695.SZ, 成交量1179，成交价61.63\n",
      "2021-03-23, 买入300768.SZ, 成交量22746，成交价37.20\n",
      "2021-03-23, 买入300486.SZ, 成交量36696，成交价23.00\n",
      "2021-03-23, 买入300521.SZ, 成交量28510，成交价29.38\n",
      "2021-05-10, 卖出300486.SZ, 成交量-36696，成交价22.57\n",
      "2021-05-10, 卖出300550.SZ, 成交量-25714，成交价35.61\n",
      "2021-05-10, 卖出300768.SZ, 成交量-22746，成交价35.27\n",
      "2021-05-10, 卖出300521.SZ, 成交量-28510，成交价36.37\n",
      "2021-05-10, 买入300695.SZ, 成交量1635，成交价55.42\n",
      "2021-05-10, 买入300069.SZ, 成交量32780，成交价26.14\n",
      "2021-05-10, 买入300371.SZ, 成交量19155，成交价45.00\n",
      "2021-05-10, 买入300649.SZ, 成交量30897，成交价27.76\n",
      "2021-05-10, 买入300321.SZ, 成交量24951，成交价35.03\n",
      "2021-06-22, 卖出300321.SZ, 成交量-24951，成交价38.33\n",
      "2021-06-22, 卖出300649.SZ, 成交量-30897，成交价43.74\n",
      "2021-06-22, 卖出300069.SZ, 成交量-32780，成交价41.15\n",
      "2021-06-22, 卖出300371.SZ, 成交量-19155，成交价51.86\n",
      "2021-06-22, 买入300695.SZ, 成交量3687，成交价55.73\n",
      "2021-06-22, 买入300583.SZ, 成交量49926，成交价21.30\n",
      "2021-06-22, 买入300662.SZ, 成交量17673，成交价60.21\n",
      "2021-06-22, 买入300683.SZ, 成交量26580，成交价41.15\n",
      "2021-06-22, 买入300833.SZ, 成交量21342，成交价49.53\n",
      "2021-08-03, 卖出300833.SZ, 成交量-21342，成交价66.33\n",
      "2021-08-03, 卖出300662.SZ, 成交量-17673，成交价55.12\n",
      "2021-08-03, 卖出300683.SZ, 成交量-26580，成交价40.47\n",
      "2021-08-03, 买入300695.SZ, 成交量1981，成交价53.19\n",
      "2021-08-03, 买入300321.SZ, 成交量30419，成交价36.92\n",
      "2021-08-03, 买入300851.SZ, 成交量34749，成交价32.21\n",
      "2021-08-03, 买入300616.SZ, 成交量8828，成交价126.01\n",
      "2021-08-03, 买入300583.SZ, 成交量145，成交价22.35\n",
      "2021-09-14, 卖出300616.SZ, 成交量-8828，成交价92.26\n",
      "2021-09-14, 卖出300695.SZ, 成交量-21130，成交价59.15\n",
      "2021-09-14, 卖出300851.SZ, 成交量-34749，成交价34.91\n",
      "2021-09-14, 卖出300321.SZ, 成交量-30419，成交价45.94\n",
      "2021-09-14, 卖出300583.SZ, 成交量-50071，成交价24.47\n",
      "2021-09-14, 买入300492.SZ, 成交量13228，成交价87.89\n",
      "2021-09-14, 买入300396.SZ, 成交量13268，成交价88.67\n",
      "2021-09-14, 买入300584.SZ, 成交量44170，成交价26.52\n",
      "2021-09-14, 买入300841.SZ, 成交量4395，成交价266.32\n",
      "2021-09-14, 买入300768.SZ, 成交量28962，成交价42.03\n",
      "2021-11-04, 卖出300768.SZ, 成交量-28962，成交价43.06\n",
      "2021-11-04, 卖出300841.SZ, 成交量-4395，成交价243.01\n",
      "2021-11-04, 卖出300396.SZ, 成交量-13268，成交价80.02\n",
      "2021-11-04, 买入300695.SZ, 成交量20472，成交价54.59\n",
      "2021-11-04, 买入300442.SZ, 成交量28704，成交价39.86\n",
      "2021-11-04, 买入300584.SZ, 成交量1304，成交价24.60\n",
      "2021-11-04, 卖出300492.SZ, 成交量-768，成交价90.51\n",
      "2021-11-04, 买入300436.SZ, 成交量19223，成交价58.20\n",
      "2021-12-16, 卖出300695.SZ, 成交量-20472，成交价64.73\n",
      "2021-12-16, 卖出300436.SZ, 成交量-19223，成交价63.16\n",
      "2021-12-16, 卖出300584.SZ, 成交量-45474，成交价27.75\n",
      "2021-12-16, 买入300492.SZ, 成交量1881，成交价83.84\n",
      "2021-12-16, 买入300683.SZ, 成交量25059，成交价47.45\n",
      "2021-12-16, 买入300583.SZ, 成交量52190，成交价23.15\n",
      "2021-12-16, 买入300721.SZ, 成交量23209，成交价51.82\n",
      "2021-12-16, 卖出300442.SZ, 成交量-110，成交价42.14\n",
      "2022-01-28, 卖出300583.SZ, 成交量-52190，成交价23.56\n",
      "2022-01-28, 卖出300721.SZ, 成交量-23209，成交价45.20\n",
      "2022-01-28, 卖出300683.SZ, 成交量-25059，成交价57.34\n",
      "2022-01-28, 买入300695.SZ, 成交量19333，成交价59.84\n",
      "2022-01-28, 买入300492.SZ, 成交量3654，成交价64.39\n",
      "2022-01-28, 买入300910.SZ, 成交量15601，成交价73.65\n",
      "2022-01-28, 卖出300442.SZ, 成交量-507，成交价41.31\n",
      "2022-01-28, 买入300851.SZ, 成交量41861，成交价27.80\n",
      "2022-03-18, 卖出300442.SZ, 成交量-28087，成交价42.08\n",
      "2022-03-18, 卖出300851.SZ, 成交量-41861，成交价26.51\n",
      "2022-03-18, 卖出300910.SZ, 成交量-15601，成交价51.96\n",
      "2022-03-18, 卖出300492.SZ, 成交量-1220，成交价64.44\n",
      "2022-03-18, 买入300695.SZ, 成交量325，成交价53.83\n",
      "2022-03-18, 买入300530.SZ, 成交量15843，成交价67.40\n",
      "2022-03-18, 买入300069.SZ, 成交量28700，成交价37.24\n",
      "2022-03-18, 买入300321.SZ, 成交量27812，成交价38.28\n",
      "2022-05-06, 卖出300321.SZ, 成交量-27812，成交价30.47\n",
      "2022-05-06, 买入300392.SZ, 成交量49151，成交价15.71\n",
      "2022-05-06, 卖出300492.SZ, 成交量-195，成交价59.60\n",
      "2022-05-06, 卖出300695.SZ, 成交量-672，成交价50.07\n",
      "2022-05-06, 买入300069.SZ, 成交量1148，成交价31.77\n",
      "2022-05-06, 卖出300530.SZ, 成交量-517，成交价62.92\n",
      "2022-06-20, 卖出300392.SZ, 成交量-49151，成交价17.34\n",
      "2022-06-20, 卖出300069.SZ, 成交量-29848，成交价38.73\n",
      "2022-06-20, 卖出300492.SZ, 成交量-245，成交价64.97\n",
      "2022-06-20, 买入300695.SZ, 成交量64，成交价56.08\n",
      "2022-06-20, 卖出300530.SZ, 成交量-498，成交价72.21\n",
      "2022-06-20, 买入300851.SZ, 成交量46897，成交价23.05\n",
      "2022-06-20, 买入300442.SZ, 成交量22241，成交价47.93\n",
      "2022-08-01, 卖出300695.SZ, 成交量-19050，成交价61.07\n",
      "2022-08-01, 卖出300851.SZ, 成交量-46897，成交价24.21\n",
      "2022-08-01, 买入300492.SZ, 成交量325，成交价64.05\n",
      "2022-08-01, 买入300321.SZ, 成交量29612，成交价36.73\n",
      "2022-08-01, 买入300530.SZ, 成交量1691，成交价64.99\n",
      "2022-08-01, 买入300442.SZ, 成交量400，成交价46.53\n",
      "2022-08-01, 买入300983.SZ, 成交量18668，成交价57.13\n",
      "2022-09-13, 卖出300321.SZ, 成交量-29612，成交价36.67\n",
      "2022-09-13, 卖出300442.SZ, 成交量-22641，成交价49.12\n",
      "2022-09-13, 卖出300983.SZ, 成交量-18668，成交价55.14\n",
      "2022-09-13, 卖出300530.SZ, 成交量-16519，成交价82.13\n",
      "2022-09-13, 买入430047.BJ, 成交量235，成交价4722.10\n",
      "2022-09-13, 买入300492.SZ, 成交量668，成交价64.26\n",
      "2022-09-13, 买入301051.SZ, 成交量19219，成交价57.90\n",
      "2022-09-13, 买入301019.SZ, 成交量33369，成交价33.50\n",
      "2022-09-13, 买入300862.SZ, 成交量42226，成交价26.36\n",
      "2022-11-01, 卖出301019.SZ, 成交量-33369，成交价30.97\n",
      "2022-11-01, 卖出300862.SZ, 成交量-42226，成交价25.01\n",
      "2022-11-01, 卖出301051.SZ, 成交量-19219，成交价48.56\n",
      "2022-11-01, 买入300492.SZ, 成交量74，成交价60.42\n",
      "2022-11-01, 买入300983.SZ, 成交量22164，成交价47.20\n",
      "2022-11-01, 卖出430047.BJ, 成交量-10，成交价4613.70\n",
      "2022-11-01, 买入300897.SZ, 成交量36079，成交价29.10\n",
      "2022-11-01, 买入300834.SZ, 成交量39101，成交价26.56\n",
      "2022-12-13, 卖出300834.SZ, 成交量-39101，成交价27.80\n",
      "2022-12-13, 卖出300983.SZ, 成交量-22164，成交价50.13\n",
      "2022-12-13, 买入300492.SZ, 成交量886，成交价61.60\n",
      "2022-12-13, 买入300695.SZ, 成交量22858，成交价49.13\n",
      "2022-12-13, 卖出430047.BJ, 成交量-36，成交价5962.25\n",
      "2022-12-13, 买入300897.SZ, 成交量2227，成交价29.59\n",
      "2022-12-13, 买入301019.SZ, 成交量35270，成交价31.86\n",
      "2023-02-01, 卖出301019.SZ, 成交量-35270，成交价31.25\n",
      "2023-02-01, 卖出300492.SZ, 成交量-18288，成交价85.81\n",
      "2023-02-01, 卖出430047.BJ, 成交量-189，成交价6447.90\n",
      "2023-02-01, 卖出300897.SZ, 成交量-38306，成交价29.93\n",
      "2023-02-01, 买入300695.SZ, 成交量1526，成交价50.35\n",
      "2023-02-01, 买入300530.SZ, 成交量19780，成交价62.08\n",
      "2023-02-01, 买入300983.SZ, 成交量25430，成交价48.35\n",
      "2023-02-01, 买入301070.SZ, 成交量46900，成交价26.48\n",
      "2023-02-01, 买入301196.SZ, 成交量34164，成交价36.07\n",
      "最终资金: 7093897.37\n",
      "夏普比率: OrderedDict([('sharperatio', 0.816940297141307)])\n",
      "回撤指标: AutoOrderedDict([('len', 256), ('drawdown', 4.090498206614732), ('moneydown', 302551.6128245983), ('max', AutoOrderedDict([('len', 256), ('drawdown', 34.586845596209635), ('moneydown', 2396461.2664233996)]))])\n"
     ]
    }
   ],
   "source": [
    "start=datetime(2018,2,22)\n",
    "end=datetime(2023,2,10)\n",
    "cash_value={}\n",
    "result=huice_run_num(start,end,stock_list,my_strategy_date_2)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "eede5608",
   "metadata": {},
   "source": [
    "## 交易方案构建函数的优化\n",
    "\n",
    "### 处理停牌与涨跌停板\n",
    "\n",
    "在两个部分都可以处理\n",
    "\n",
    "* 策略\n",
    "* 构建函数-实现确定股票池"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "ec13dc23",
   "metadata": {},
   "outputs": [],
   "source": [
    "#stock_daily.isnull().sum()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "a255f2e7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array(['300001.SZ', '300002.SZ', '300003.SZ', '300004.SZ', '300005.SZ',\n",
       "       '300006.SZ', '300007.SZ', '300008.SZ', '300009.SZ', '300011.SZ',\n",
       "       '300012.SZ', '300013.SZ', '300014.SZ', '300015.SZ', '300016.SZ',\n",
       "       '300017.SZ', '300018.SZ', '300019.SZ', '300020.SZ', '300021.SZ',\n",
       "       '300022.SZ', '300023.SZ', '300024.SZ', '300025.SZ', '300026.SZ',\n",
       "       '300027.SZ', '300028.SZ', '300029.SZ', '300030.SZ', '300031.SZ',\n",
       "       '300033.SZ', '300034.SZ', '300035.SZ', '300036.SZ', '300037.SZ',\n",
       "       '300039.SZ', '300040.SZ', '300041.SZ', '300043.SZ', '300044.SZ',\n",
       "       '300046.SZ', '300047.SZ', '300048.SZ', '300050.SZ', '300051.SZ',\n",
       "       '300052.SZ', '300053.SZ', '300054.SZ', '300055.SZ', '300056.SZ',\n",
       "       '300057.SZ', '300058.SZ', '300059.SZ', '300061.SZ', '300062.SZ',\n",
       "       '300063.SZ', '300065.SZ', '300066.SZ', '300067.SZ', '300068.SZ',\n",
       "       '300069.SZ', '300070.SZ', '300072.SZ', '300073.SZ', '300074.SZ',\n",
       "       '300075.SZ', '300076.SZ', '300077.SZ', '300078.SZ', '300079.SZ',\n",
       "       '300080.SZ', '300081.SZ', '300082.SZ', '300083.SZ', '300084.SZ',\n",
       "       '300085.SZ', '300087.SZ', '300088.SZ', '300089.SZ', '300091.SZ',\n",
       "       '300092.SZ', '300093.SZ', '300094.SZ', '300095.SZ', '300096.SZ',\n",
       "       '300097.SZ', '300098.SZ', '300099.SZ', '300100.SZ', '300101.SZ',\n",
       "       '300102.SZ', '300103.SZ', '300104.SZ', '300105.SZ', '300106.SZ',\n",
       "       '300107.SZ', '300108.SZ', '300109.SZ', '300110.SZ', '300111.SZ',\n",
       "       '300112.SZ', '300113.SZ', '300114.SZ', '300115.SZ', '300117.SZ',\n",
       "       '300118.SZ', '300119.SZ', '300120.SZ', '300121.SZ', '300122.SZ',\n",
       "       '300123.SZ', '300124.SZ', '300125.SZ', '300126.SZ', '300127.SZ',\n",
       "       '300128.SZ', '300129.SZ', '300130.SZ', '300131.SZ', '300132.SZ',\n",
       "       '300133.SZ', '300135.SZ', '300136.SZ', '300137.SZ', '300138.SZ',\n",
       "       '300139.SZ', '300140.SZ', '300141.SZ', '300142.SZ', '300144.SZ',\n",
       "       '300145.SZ', '300146.SZ', '300147.SZ', '300148.SZ', '300149.SZ',\n",
       "       '300150.SZ', '300151.SZ', '300152.SZ', '300153.SZ', '300154.SZ',\n",
       "       '300155.SZ', '300156.SZ', '300157.SZ', '300158.SZ', '300160.SZ',\n",
       "       '300161.SZ', '300162.SZ', '300163.SZ', '300164.SZ', '300165.SZ',\n",
       "       '300166.SZ', '300168.SZ', '300169.SZ', '300170.SZ', '300171.SZ',\n",
       "       '300172.SZ', '300174.SZ', '300175.SZ', '300176.SZ', '300177.SZ',\n",
       "       '300178.SZ', '300179.SZ', '300180.SZ', '300181.SZ', '300182.SZ',\n",
       "       '300183.SZ', '300184.SZ', '300185.SZ', '300187.SZ', '300188.SZ',\n",
       "       '300189.SZ', '300190.SZ', '300191.SZ', '300192.SZ', '300193.SZ',\n",
       "       '300194.SZ', '300195.SZ', '300196.SZ', '300197.SZ', '300198.SZ',\n",
       "       '300199.SZ', '300200.SZ', '300201.SZ', '300202.SZ', '300203.SZ',\n",
       "       '300204.SZ', '300205.SZ', '300206.SZ', '300207.SZ', '300208.SZ',\n",
       "       '300209.SZ', '300210.SZ', '300211.SZ', '300212.SZ', '300213.SZ',\n",
       "       '300214.SZ', '300215.SZ', '300216.SZ', '300217.SZ', '300218.SZ',\n",
       "       '300219.SZ', '300220.SZ', '300221.SZ', '300222.SZ', '300223.SZ',\n",
       "       '300224.SZ', '300225.SZ', '300226.SZ', '300227.SZ', '300228.SZ',\n",
       "       '300229.SZ', '300230.SZ', '300231.SZ', '300232.SZ', '300233.SZ',\n",
       "       '300234.SZ', '300235.SZ', '300236.SZ', '300237.SZ', '300238.SZ',\n",
       "       '300239.SZ', '300241.SZ', '300242.SZ', '300243.SZ', '300244.SZ',\n",
       "       '300245.SZ', '300246.SZ', '300247.SZ', '300248.SZ', '300249.SZ',\n",
       "       '300250.SZ', '300251.SZ', '300252.SZ', '300253.SZ', '300254.SZ',\n",
       "       '300255.SZ', '300256.SZ', '300257.SZ', '300258.SZ', '300259.SZ',\n",
       "       '300260.SZ', '300261.SZ', '300262.SZ', '300263.SZ', '300264.SZ',\n",
       "       '300265.SZ', '300266.SZ', '300267.SZ', '300268.SZ', '300269.SZ',\n",
       "       '300270.SZ', '300271.SZ', '300272.SZ', '300273.SZ', '300274.SZ',\n",
       "       '300275.SZ', '300276.SZ', '300279.SZ', '300280.SZ', '300281.SZ',\n",
       "       '300282.SZ', '300283.SZ', '300284.SZ', '300285.SZ', '300286.SZ',\n",
       "       '300287.SZ', '300288.SZ', '300289.SZ', '300290.SZ', '300291.SZ',\n",
       "       '300293.SZ', '300294.SZ', '300295.SZ', '300296.SZ', '300297.SZ',\n",
       "       '300298.SZ', '300299.SZ', '300300.SZ', '300301.SZ', '300302.SZ',\n",
       "       '300303.SZ', '300304.SZ', '300305.SZ', '300306.SZ', '300307.SZ',\n",
       "       '300308.SZ', '300309.SZ', '300310.SZ', '300311.SZ', '300312.SZ',\n",
       "       '300313.SZ', '300314.SZ', '300315.SZ', '300316.SZ', '300317.SZ',\n",
       "       '300318.SZ', '300319.SZ', '300320.SZ', '300321.SZ', '300322.SZ',\n",
       "       '300323.SZ', '300324.SZ', '300325.SZ', '300327.SZ', '300328.SZ',\n",
       "       '300329.SZ', '300330.SZ', '300331.SZ', '300332.SZ', '300333.SZ',\n",
       "       '300334.SZ', '300335.SZ', '300336.SZ', '300337.SZ', '300338.SZ',\n",
       "       '300339.SZ', '300340.SZ', '300341.SZ', '300342.SZ', '300343.SZ',\n",
       "       '300344.SZ', '300345.SZ', '300346.SZ', '300347.SZ', '300348.SZ',\n",
       "       '300349.SZ', '300350.SZ', '300351.SZ', '300352.SZ', '300353.SZ',\n",
       "       '300354.SZ', '300355.SZ', '300357.SZ', '300358.SZ', '300359.SZ',\n",
       "       '300360.SZ', '300362.SZ', '300363.SZ', '300364.SZ', '300365.SZ',\n",
       "       '300366.SZ', '300367.SZ', '300368.SZ', '300370.SZ', '300371.SZ',\n",
       "       '300373.SZ', '300374.SZ', '300375.SZ', '300376.SZ', '300377.SZ',\n",
       "       '300378.SZ', '300379.SZ', '300380.SZ', '300381.SZ', '300382.SZ',\n",
       "       '300384.SZ', '300385.SZ', '300386.SZ', '300387.SZ', '300388.SZ',\n",
       "       '300389.SZ', '300390.SZ', '300391.SZ', '300393.SZ', '300394.SZ',\n",
       "       '300395.SZ', '300396.SZ', '300397.SZ', '300398.SZ', '300399.SZ',\n",
       "       '300400.SZ', '300401.SZ', '300402.SZ', '300403.SZ', '300404.SZ',\n",
       "       '300405.SZ', '300406.SZ', '300407.SZ', '300408.SZ', '300409.SZ',\n",
       "       '300410.SZ', '300411.SZ', '300413.SZ', '300415.SZ', '300416.SZ',\n",
       "       '300417.SZ', '300418.SZ', '300419.SZ', '300420.SZ', '300421.SZ',\n",
       "       '300422.SZ', '300423.SZ', '300425.SZ', '300426.SZ', '300427.SZ',\n",
       "       '300428.SZ', '300429.SZ', '300430.SZ', '300431.SZ', '300432.SZ',\n",
       "       '300433.SZ', '300434.SZ', '300435.SZ', '300436.SZ', '300437.SZ',\n",
       "       '300438.SZ', '300439.SZ', '300440.SZ', '300442.SZ', '300443.SZ',\n",
       "       '300445.SZ', '300446.SZ', '300447.SZ', '300448.SZ', '300449.SZ',\n",
       "       '300450.SZ', '300451.SZ', '300452.SZ', '300453.SZ', '300456.SZ',\n",
       "       '300457.SZ', '300458.SZ', '300459.SZ', '300460.SZ', '300461.SZ',\n",
       "       '300462.SZ', '300463.SZ', '300464.SZ', '300465.SZ', '300466.SZ',\n",
       "       '300467.SZ', '300468.SZ', '300469.SZ', '300470.SZ', '300471.SZ',\n",
       "       '300472.SZ', '300473.SZ', '300474.SZ', '300475.SZ', '300476.SZ',\n",
       "       '300477.SZ', '300478.SZ', '300479.SZ', '300480.SZ', '300481.SZ',\n",
       "       '300482.SZ', '300483.SZ', '300484.SZ', '300485.SZ', '300486.SZ',\n",
       "       '300487.SZ', '300488.SZ', '300489.SZ', '300490.SZ', '300491.SZ',\n",
       "       '300493.SZ', '300494.SZ', '300495.SZ', '300496.SZ', '300497.SZ',\n",
       "       '300498.SZ', '300499.SZ', '300500.SZ', '300501.SZ', '300502.SZ',\n",
       "       '300503.SZ', '300505.SZ', '300506.SZ', '300507.SZ', '300508.SZ',\n",
       "       '300509.SZ', '300510.SZ', '300511.SZ', '300512.SZ', '300513.SZ',\n",
       "       '300514.SZ', '300515.SZ', '300516.SZ', '300517.SZ', '300518.SZ',\n",
       "       '300519.SZ', '300520.SZ', '300521.SZ', '300522.SZ', '300525.SZ',\n",
       "       '300526.SZ', '300527.SZ', '300528.SZ', '300529.SZ', '300530.SZ',\n",
       "       '300531.SZ', '300532.SZ', '300533.SZ', '300534.SZ', '300535.SZ',\n",
       "       '300536.SZ', '300537.SZ', '300538.SZ', '300539.SZ', '300540.SZ',\n",
       "       '300541.SZ', '300542.SZ', '300543.SZ', '300545.SZ', '300546.SZ',\n",
       "       '300547.SZ', '300548.SZ', '300549.SZ', '300550.SZ', '300551.SZ',\n",
       "       '300552.SZ', '300553.SZ', '300554.SZ', '300555.SZ', '300556.SZ',\n",
       "       '300557.SZ', '300558.SZ', '300559.SZ', '300560.SZ', '300561.SZ',\n",
       "       '300562.SZ', '300563.SZ', '300565.SZ', '300566.SZ', '300567.SZ',\n",
       "       '300568.SZ', '300569.SZ', '300570.SZ', '300571.SZ', '300572.SZ',\n",
       "       '300573.SZ', '300575.SZ', '300576.SZ', '300577.SZ', '300579.SZ',\n",
       "       '300581.SZ', '300582.SZ', '300583.SZ', '300584.SZ', '300585.SZ',\n",
       "       '300586.SZ', '300587.SZ', '300588.SZ', '300589.SZ', '300590.SZ',\n",
       "       '300591.SZ', '300592.SZ', '300595.SZ', '300596.SZ', '300597.SZ',\n",
       "       '300598.SZ', '300599.SZ', '300600.SZ', '300601.SZ', '300602.SZ',\n",
       "       '300603.SZ', '300604.SZ', '300605.SZ', '300606.SZ', '300607.SZ',\n",
       "       '300608.SZ', '300609.SZ', '300610.SZ', '300611.SZ', '300612.SZ',\n",
       "       '300613.SZ', '300615.SZ', '300616.SZ', '300617.SZ', '300618.SZ',\n",
       "       '300619.SZ', '300620.SZ', '300621.SZ', '300622.SZ', '300623.SZ',\n",
       "       '300624.SZ', '300625.SZ', '300626.SZ', '300627.SZ', '300628.SZ',\n",
       "       '300629.SZ', '300630.SZ', '300631.SZ', '300632.SZ', '300633.SZ',\n",
       "       '300635.SZ', '300636.SZ', '300637.SZ', '300638.SZ', '300639.SZ',\n",
       "       '300640.SZ', '300641.SZ', '300642.SZ', '300643.SZ', '300645.SZ',\n",
       "       '300647.SZ', '300648.SZ', '300649.SZ', '300650.SZ', '300651.SZ',\n",
       "       '300652.SZ', '300653.SZ', '300654.SZ', '300655.SZ', '300657.SZ',\n",
       "       '300658.SZ', '300660.SZ', '300661.SZ', '300662.SZ', '300663.SZ',\n",
       "       '300664.SZ', '300665.SZ', '300666.SZ', '300667.SZ', '300668.SZ',\n",
       "       '300669.SZ', '300670.SZ', '300671.SZ', '300672.SZ', '300673.SZ',\n",
       "       '300675.SZ', '300676.SZ', '300677.SZ', '300678.SZ', '300679.SZ',\n",
       "       '300681.SZ', '300683.SZ', '300684.SZ', '300685.SZ', '300686.SZ',\n",
       "       '300687.SZ', '300688.SZ', '300689.SZ', '300690.SZ', '300691.SZ',\n",
       "       '300692.SZ', '300693.SZ', '300695.SZ', '300696.SZ', '300697.SZ',\n",
       "       '300698.SZ', '300699.SZ', '300700.SZ', '300701.SZ', '300702.SZ',\n",
       "       '300703.SZ', '300705.SZ', '300706.SZ', '300707.SZ', '300708.SZ',\n",
       "       '300709.SZ', '300710.SZ', '300711.SZ', '300712.SZ', '300713.SZ',\n",
       "       '300715.SZ', '300716.SZ', '300717.SZ', '300718.SZ', '300719.SZ',\n",
       "       '300720.SZ', '300721.SZ', '300722.SZ', '300723.SZ', '300725.SZ',\n",
       "       '300726.SZ', '300727.SZ', '300729.SZ', '300730.SZ', '300731.SZ',\n",
       "       '300732.SZ', '300733.SZ', '300735.SZ', '300736.SZ', '300737.SZ',\n",
       "       '300738.SZ'], dtype=object)"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stock_daily[stock_daily[\"date\"]==time_id[20]][\"股票代码\"].unique()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "1e253e84",
   "metadata": {},
   "outputs": [],
   "source": [
    "time_id=pd.Series(stock_daily.date.unique()).sort_values().tolist()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "2b1eff16",
   "metadata": {},
   "outputs": [],
   "source": [
    "buy_date={}\n",
    "sell_date={}\n",
    "postion=set([])\n",
    "stock_list=set([])\n",
    "for i in range(0,len(time_id),30):\n",
    "    stock_list_tem=stock_daily[(stock_daily[\"date\"]==time_id[i+1])&(stock_daily[\"open\"]!=stock_daily[\"close\"])][\"股票代码\"].unique()\n",
    "    \n",
    "    stock_list_tem_0=stock_daily[(stock_daily[\"date\"]==time_id[i])&(stock_daily[\"股票代码\"].isin(stock_list_tem))]\n",
    "    factor1_stock=stock_list_tem_0.sort_values(by='总市值(万元)',ascending=True)[\"股票代码\"].tolist()\n",
    "    factor2_stock=stock_list_tem_0.sort_values(by='市盈率(静态)',ascending=False)[\"股票代码\"].tolist()\n",
    "    f_1_df=pd.Series(range(1,len(factor1_stock)+1),index=factor1_stock)\n",
    "    f_2_df=pd.Series(range(1,len(factor2_stock)+1),index=factor2_stock)\n",
    "    f_1_2=pd.concat([f_1_df,f_2_df],axis=1)\n",
    "    f_1_2[2]=f_1_2[0]+f_1_2[1]\n",
    "    \n",
    "    buy_list=f_1_2.sort_values(by=2).head(5).index.tolist()\n",
    "    buy_date.update({str(time_id[i].date()):buy_list})\n",
    "    sell_date.update({str(time_id[i].date()):list(postion-set(buy_list))})\n",
    "    postion=set(buy_list)\n",
    "    stock_list=stock_list|postion"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "19304d4d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2018-02-22 2023-02-10\n",
      "初始资金: 100000.00\n",
      "2018-04-04, 买入300354.SZ, 成交量434，成交价44.34\n",
      "2018-04-04, 买入300093.SZ, 成交量1122，成交价16.09\n",
      "2018-04-04, 买入300092.SZ, 成交量939，成交价19.34\n",
      "2018-04-04, 买入300211.SZ, 成交量426，成交价42.51\n",
      "2018-04-04, 买入300126.SZ, 成交量746，成交价24.04\n",
      "2018-05-22, 卖出300093.SZ, 成交量-1122，成交价15.87\n",
      "2018-05-22, 买入300354.SZ, 成交量28，成交价37.70\n",
      "2018-05-22, 买入300126.SZ, 成交量10，成交价22.84\n",
      "2018-05-22, 买入300330.SZ, 成交量769，成交价22.84\n",
      "2018-05-22, 卖出300211.SZ, 成交量-14，成交价42.26\n",
      "2018-05-22, 卖出300092.SZ, 成交量-73，成交价20.01\n",
      "2018-07-04, 买入300354.SZ, 成交量1，成交价31.60\n",
      "2018-07-04, 买入300211.SZ, 成交量13，成交价34.27\n",
      "2018-07-04, 买入300126.SZ, 成交量16，成交价19.02\n",
      "2018-07-04, 买入300092.SZ, 成交量45，成交价16.05\n",
      "2018-07-04, 卖出300330.SZ, 成交量-25，成交价19.89\n",
      "2018-08-15, 卖出300211.SZ, 成交量-425，成交价34.78\n",
      "2018-08-15, 卖出300126.SZ, 成交量-772，成交价19.68\n",
      "2018-08-15, 买入300354.SZ, 成交量14，成交价30.51\n",
      "2018-08-15, 买入300330.SZ, 成交量50，成交价18.35\n",
      "2018-08-15, 买入300483.SZ, 成交量607，成交价23.92\n",
      "2018-08-15, 买入300268.SZ, 成交量594，成交价24.16\n",
      "2018-08-15, 卖出300092.SZ, 成交量-9，成交价16.05\n",
      "2018-09-27, 卖出300092.SZ, 成交量-902，成交价19.67\n",
      "2018-09-27, 卖出300483.SZ, 成交量-607，成交价27.07\n",
      "2018-09-27, 买入300354.SZ, 成交量32，成交价29.75\n",
      "2018-09-27, 买入300268.SZ, 成交量54，成交价23.31\n",
      "2018-09-27, 买入300126.SZ, 成交量817，成交价18.44\n",
      "2018-09-27, 买入300330.SZ, 成交量81，成交价17.31\n",
      "2018-09-27, 买入300211.SZ, 成交量462，成交价32.74\n",
      "2018-11-15, 卖出300126.SZ, 成交量-817，成交价20.99\n",
      "2018-11-15, 买入300268.SZ, 成交量62，成交价21.16\n",
      "2018-11-15, 买入300354.SZ, 成交量3，成交价29.23\n",
      "2018-11-15, 买入300330.SZ, 成交量12，成交价16.88\n",
      "2018-11-15, 买入300211.SZ, 成交量9，成交价31.85\n",
      "2018-11-15, 买入300442.SZ, 成交量1046，成交价14.51\n",
      "2018-12-27, 卖出300442.SZ, 成交量-1046，成交价13.25\n",
      "2018-12-27, 买入300354.SZ, 成交量30，成交价26.65\n",
      "2018-12-27, 买入300330.SZ, 成交量51，成交价15.43\n",
      "2018-12-27, 卖出300268.SZ, 成交量-65，成交价22.72\n",
      "2018-12-27, 卖出300211.SZ, 成交量-13，成交价31.60\n",
      "2018-12-27, 买入300092.SZ, 成交量921，成交价15.71\n",
      "2019-02-18, 卖出300092.SZ, 成交量-921，成交价17.60\n",
      "2019-02-18, 卖出300268.SZ, 成交量-645，成交价26.74\n",
      "2019-02-18, 买入300354.SZ, 成交量5，成交价28.40\n",
      "2019-02-18, 买入300330.SZ, 成交量66，成交价15.49\n",
      "2019-02-18, 买入300211.SZ, 成交量11，成交价33.00\n",
      "2019-02-18, 买入300442.SZ, 成交量1220，成交价12.80\n",
      "2019-02-18, 买入300126.SZ, 成交量800，成交价19.95\n",
      "2019-04-01, 卖出300211.SZ, 成交量-469，成交价45.74\n",
      "2019-04-01, 买入300354.SZ, 成交量2，成交价35.43\n",
      "2019-04-01, 卖出300330.SZ, 成交量-57，成交价20.46\n",
      "2019-04-01, 买入300442.SZ, 成交量73，成交价15.01\n",
      "2019-04-01, 买入300235.SZ, 成交量511，成交价37.77\n",
      "2019-04-01, 卖出300126.SZ, 成交量-20，成交价24.94\n",
      "2019-05-17, 卖出300330.SZ, 成交量-947，成交价18.85\n",
      "2019-05-17, 卖出300235.SZ, 成交量-511，成交价35.85\n",
      "2019-05-17, 卖出300354.SZ, 成交量-549，成交价36.58\n",
      "2019-05-17, 卖出300442.SZ, 成交量-1293，成交价14.30\n",
      "2019-05-17, 卖出300126.SZ, 成交量-780，成交价23.35\n",
      "2019-05-17, 买入300489.SZ, 成交量539，成交价34.06\n",
      "2019-05-17, 买入300680.SZ, 成交量950，成交价19.50\n",
      "2019-05-17, 买入300254.SZ, 成交量1486，成交价12.38\n",
      "2019-05-17, 买入300092.SZ, 成交量926，成交价19.83\n",
      "2019-05-17, 买入300211.SZ, 成交量463，成交价43.43\n",
      "2019-07-01, 卖出300211.SZ, 成交量-463，成交价43.75\n",
      "2019-07-01, 卖出300489.SZ, 成交量-1，成交价34.94\n",
      "2019-07-01, 卖出300680.SZ, 成交量-50，成交价20.10\n",
      "2019-07-01, 买入300254.SZ, 成交量97，成交价11.88\n",
      "2019-07-01, 买入300092.SZ, 成交量34，成交价19.65\n",
      "2019-07-01, 买入300141.SZ, 成交量552，成交价33.95\n",
      "2019-08-12, 买入300680.SZ, 成交量16，成交价18.63\n",
      "2019-08-12, 卖出300489.SZ, 成交量-34，成交价33.86\n",
      "2019-08-12, 买入300092.SZ, 成交量53，成交价16.94\n",
      "2019-08-12, 卖出300254.SZ, 成交量-46，成交价11.10\n",
      "2019-08-12, 买入300141.SZ, 成交量40，成交价28.69\n",
      "2019-09-24, 卖出300680.SZ, 成交量-21，成交价21.19\n",
      "2019-09-24, 卖出300489.SZ, 成交量-16，成交价38.47\n",
      "2019-09-24, 买入300092.SZ, 成交量12，成交价18.45\n",
      "2019-09-24, 卖出300254.SZ, 成交量-5，成交价12.36\n",
      "2019-09-24, 卖出300141.SZ, 成交量-3，成交价31.93\n",
      "2019-11-12, 卖出300680.SZ, 成交量-1，成交价19.65\n",
      "2019-11-12, 买入300489.SZ, 成交量15，成交价35.10\n",
      "2019-11-12, 卖出300092.SZ, 成交量-11，成交价17.55\n",
      "2019-11-12, 买入300254.SZ, 成交量17，成交价11.40\n",
      "2019-11-12, 买入300141.SZ, 成交量5，成交价29.63\n",
      "2019-12-24, 卖出300680.SZ, 成交量-51，成交价21.96\n",
      "2019-12-24, 卖出300489.SZ, 成交量-20，成交价38.49\n",
      "2019-12-24, 买入300141.SZ, 成交量33，成交价29.58\n",
      "2019-12-24, 买入300254.SZ, 成交量33，成交价11.67\n",
      "2019-12-24, 买入300092.SZ, 成交量5，成交价18.14\n",
      "2020-02-13, 卖出300254.SZ, 成交量-1582，成交价13.31\n",
      "2020-02-13, 买入300680.SZ, 成交量100，成交价20.42\n",
      "2020-02-13, 买入300092.SZ, 成交量128，成交价16.81\n",
      "2020-02-13, 买入300141.SZ, 成交量12，成交价29.96\n",
      "2020-02-13, 买入300539.SZ, 成交量1294，成交价14.90\n",
      "2020-02-13, 卖出300489.SZ, 成交量-69，成交价47.08\n",
      "2020-03-26, 卖出300539.SZ, 成交量-1294，成交价15.57\n",
      "2020-03-26, 卖出300489.SZ, 成交量-414，成交价74.22\n",
      "2020-03-26, 卖出300141.SZ, 成交量-639，成交价53.91\n",
      "2020-03-26, 买入300254.SZ, 成交量2123，成交价11.67\n",
      "2020-03-26, 买入300721.SZ, 成交量1124，成交价21.80\n",
      "2020-03-26, 买入300680.SZ, 成交量26，成交价27.20\n",
      "2020-03-26, 买入300092.SZ, 成交量121，成交价19.55\n",
      "2020-03-26, 买入300022.SZ, 成交量1549，成交价16.09\n",
      "2020-05-13, 卖出300022.SZ, 成交量-1549，成交价21.81\n",
      "2020-05-13, 卖出300092.SZ, 成交量-1268，成交价18.22\n",
      "2020-05-13, 卖出300680.SZ, 成交量-969，成交价24.62\n",
      "2020-05-13, 买入300254.SZ, 成交量372，成交价9.99\n",
      "2020-05-13, 买入300330.SZ, 成交量1313，成交价19.05\n",
      "2020-05-13, 买入300721.SZ, 成交量224，成交价18.29\n",
      "2020-05-13, 买入300312.SZ, 成交量1581，成交价15.71\n",
      "2020-05-13, 买入300555.SZ, 成交量1180，成交价21.19\n",
      "2020-06-24, 卖出300330.SZ, 成交量-1313，成交价22.60\n",
      "2020-06-24, 买入300312.SZ, 成交量514，成交价12.22\n",
      "2020-06-24, 买入300254.SZ, 成交量53，成交价10.16\n",
      "2020-06-24, 买入300153.SZ, 成交量1151，成交价22.44\n",
      "2020-06-24, 买入300555.SZ, 成交量50，成交价21.02\n",
      "2020-06-24, 卖出300721.SZ, 成交量-121，成交价21.13\n",
      "2020-08-07, 卖出300721.SZ, 成交量-1227，成交价24.59\n",
      "2020-08-07, 买入300153.SZ, 成交量55，成交价24.48\n",
      "2020-08-07, 卖出300312.SZ, 成交量-150，成交价15.01\n",
      "2020-08-07, 卖出300254.SZ, 成交量-84，成交价11.68\n",
      "2020-08-07, 买入300555.SZ, 成交量33，成交价23.29\n",
      "2020-08-07, 买入300330.SZ, 成交量1128，成交价26.05\n",
      "2020-09-18, 买入300254.SZ, 成交量124，成交价13.16\n",
      "2020-09-18, 卖出300153.SZ, 成交量-69，成交价29.50\n",
      "2020-09-18, 买入300555.SZ, 成交量68，成交价25.53\n",
      "2020-09-18, 买入300330.SZ, 成交量109，成交价27.41\n",
      "2020-09-18, 卖出300312.SZ, 成交量-329，成交价20.56\n",
      "2020-11-09, 卖出300153.SZ, 成交量-1137，成交价46.77\n",
      "2020-11-09, 卖出300312.SZ, 成交量-1616，成交价26.53\n",
      "2020-11-09, 买入300330.SZ, 成交量278，成交价26.65\n",
      "2020-11-09, 买入300254.SZ, 成交量472，成交价12.94\n",
      "2020-11-09, 买入300555.SZ, 成交量16，成交价29.87\n",
      "2020-11-09, 买入300721.SZ, 成交量1309，成交价30.47\n",
      "2020-11-09, 买入300592.SZ, 成交量2056，成交价19.15\n",
      "2020-12-21, 卖出300592.SZ, 成交量-2056，成交价17.92\n",
      "2020-12-21, 卖出300721.SZ, 成交量-1309，成交价32.00\n",
      "2020-12-21, 买入300330.SZ, 成交量102，成交价22.23\n",
      "2020-12-21, 买入300254.SZ, 成交量358，成交价10.49\n",
      "2020-12-21, 买入300312.SZ, 成交量2023，成交价18.07\n",
      "2020-12-21, 买入300555.SZ, 成交量84，成交价25.15\n",
      "2020-12-21, 买入300211.SZ, 成交量824，成交价41.98\n",
      "2021-02-02, 卖出300211.SZ, 成交量-824，成交价55.79\n",
      "2021-02-02, 买入300555.SZ, 成交量214，成交价18.70\n",
      "2021-02-02, 买入300330.SZ, 成交量86，成交价17.86\n",
      "2021-02-02, 买入300153.SZ, 成交量1377，成交价22.12\n",
      "2021-02-02, 买入300254.SZ, 成交量461，成交价7.96\n",
      "2021-02-02, 买入300312.SZ, 成交量949，成交价10.37\n",
      "2021-03-23, 买入300153.SZ, 成交量135，成交价25.26\n",
      "2021-03-23, 买入300254.SZ, 成交量282，成交价8.98\n",
      "2021-03-23, 买入300330.SZ, 成交量218，成交价19.46\n",
      "2021-03-23, 买入300555.SZ, 成交量144，成交价20.92\n",
      "2021-03-23, 卖出300312.SZ, 成交量-945，成交价18.40\n",
      "2021-05-10, 卖出300153.SZ, 成交量-1512，成交价28.76\n",
      "2021-05-10, 卖出300312.SZ, 成交量-2027，成交价9.40\n",
      "2021-05-10, 卖出300254.SZ, 成交量-4161，成交价10.22\n",
      "2021-05-10, 买入300700.SZ, 成交量2432，成交价14.69\n",
      "2021-05-10, 买入300807.SZ, 成交量1527，成交价23.41\n",
      "2021-05-10, 卖出300330.SZ, 成交量-6，成交价18.77\n",
      "2021-05-10, 卖出300555.SZ, 成交量-91，成交价22.25\n",
      "2021-05-10, 买入300345.SZ, 成交量2218，成交价16.46\n",
      "2021-06-22, 卖出300345.SZ, 成交量-2218，成交价24.56\n",
      "2021-06-22, 买入300700.SZ, 成交量86，成交价17.61\n",
      "2021-06-22, 买入300534.SZ, 成交量2074，成交价21.29\n",
      "2021-06-22, 买入300807.SZ, 成交量74，成交价27.65\n",
      "2021-06-22, 买入300555.SZ, 成交量75，成交价24.93\n",
      "2021-06-22, 卖出300330.SZ, 成交量-18，成交价23.14\n",
      "2021-08-03, 卖出300330.SZ, 成交量-1897，成交价23.06\n",
      "2021-08-03, 卖出300700.SZ, 成交量-94，成交价18.62\n",
      "2021-08-03, 买入300807.SZ, 成交量112，成交价26.06\n",
      "2021-08-03, 买入300555.SZ, 成交量75，成交价24.52\n",
      "2021-08-03, 卖出300534.SZ, 成交量-185，成交价23.58\n",
      "2021-08-03, 买入300313.SZ, 成交量3586，成交价12.47\n",
      "2021-09-14, 卖出300313.SZ, 成交量-3586，成交价20.53\n",
      "2021-09-14, 买入300700.SZ, 成交量214，成交价18.66\n",
      "2021-09-14, 买入300807.SZ, 成交量274，成交价24.51\n",
      "2021-09-14, 买入300555.SZ, 成交量344，成交价22.28\n",
      "2021-09-14, 买入300534.SZ, 成交量104，成交价24.53\n",
      "2021-09-14, 买入300330.SZ, 成交量2184，成交价22.56\n",
      "2021-11-04, 卖出300700.SZ, 成交量-19，成交价16.40\n",
      "2021-11-04, 卖出300807.SZ, 成交量-75，成交价22.80\n",
      "2021-11-04, 买入300534.SZ, 成交量271，成交价19.18\n",
      "2021-11-04, 买入300330.SZ, 成交量30，成交价19.44\n",
      "2021-12-16, 买入300700.SZ, 成交量149，成交价18.31\n",
      "2021-12-16, 买入300534.SZ, 成交量48，成交价21.64\n",
      "2021-12-16, 卖出300555.SZ, 成交量-2，成交价22.98\n",
      "2021-12-16, 买入300330.SZ, 成交量233，成交价20.50\n",
      "2021-12-16, 卖出300807.SZ, 成交量-377，成交价32.41\n",
      "2022-01-28, 卖出300534.SZ, 成交量-2312，成交价36.70\n",
      "2022-01-28, 买入300807.SZ, 成交量818，成交价23.81\n",
      "2022-01-28, 买入300555.SZ, 成交量501，成交价20.87\n",
      "2022-01-28, 买入300330.SZ, 成交量410，成交价19.68\n",
      "2022-01-28, 卖出300700.SZ, 成交量-446，成交价23.03\n",
      "2022-01-28, 买入300313.SZ, 成交量4357，成交价12.81\n",
      "2022-03-18, 卖出300330.SZ, 成交量-2857，成交价26.09\n",
      "2022-03-18, 买入300555.SZ, 成交量287，成交价20.56\n",
      "2022-03-18, 买入300313.SZ, 成交量514，成交价12.71\n",
      "2022-03-18, 卖出300807.SZ, 成交量-338，成交价29.83\n",
      "2022-03-18, 买入300700.SZ, 成交量235，成交价23.73\n",
      "2022-03-18, 买入300615.SZ, 成交量2380，成交价25.74\n",
      "2022-05-06, 卖出300807.SZ, 成交量-2015，成交价19.14\n",
      "2022-05-06, 卖出300555.SZ, 成交量-2978，成交价17.66\n",
      "2022-05-06, 卖出300700.SZ, 成交量-2557，成交价23.07\n",
      "2022-05-06, 卖出300313.SZ, 成交量-4871，成交价10.03\n",
      "2022-05-06, 卖出300615.SZ, 成交量-2380，成交价22.31\n",
      "2022-05-06, 买入300321.SZ, 成交量1657，成交价30.47\n",
      "2022-05-06, 买入300594.SZ, 成交量3565，成交价14.33\n",
      "2022-05-06, 买入300736.SZ, 成交量2368，成交价22.00\n",
      "2022-05-06, 买入300521.SZ, 成交量2644，成交价19.07\n",
      "2022-05-06, 买入300637.SZ, 成交量4015，成交价12.79\n",
      "2022-06-20, 卖出300321.SZ, 成交量-20，成交价34.85\n",
      "2022-06-20, 卖出300594.SZ, 成交量-170，成交价16.72\n",
      "2022-06-20, 买入300521.SZ, 成交量174，成交价19.85\n",
      "2022-06-20, 卖出300736.SZ, 成交量-34，成交价23.97\n",
      "2022-06-20, 卖出300637.SZ, 成交量-53，成交价14.12\n",
      "2022-08-01, 买入300321.SZ, 成交量53，成交价36.73\n",
      "2022-08-01, 卖出300594.SZ, 成交量-143，成交价18.78\n",
      "2022-08-01, 卖出300521.SZ, 成交量-143，成交价23.63\n",
      "2022-08-01, 买入300736.SZ, 成交量85，成交价25.38\n",
      "2022-08-01, 卖出300637.SZ, 成交量-64，成交价15.78\n",
      "2022-09-13, 卖出300321.SZ, 成交量-40，成交价36.67\n",
      "2022-09-13, 买入300594.SZ, 成交量311，成交价16.92\n",
      "2022-09-13, 买入300521.SZ, 成交量263，成交价20.56\n",
      "2022-09-13, 卖出300736.SZ, 成交量-329，成交价28.70\n",
      "2022-09-13, 买入300637.SZ, 成交量66，成交价15.13\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2022-11-01, 买入300321.SZ, 成交量93，成交价32.47\n",
      "2022-11-01, 买入300594.SZ, 成交量21，成交价15.75\n",
      "2022-11-01, 卖出300521.SZ, 成交量-34，成交价19.45\n",
      "2022-11-01, 卖出300736.SZ, 成交量-76，成交价28.28\n",
      "2022-11-01, 买入300637.SZ, 成交量96，成交价13.90\n",
      "2022-12-13, 卖出300736.SZ, 成交量-2014，成交价37.85\n",
      "2022-12-13, 买入300321.SZ, 成交量101，成交价34.74\n",
      "2022-12-13, 买入300521.SZ, 成交量482，成交价18.90\n",
      "2022-12-13, 买入300637.SZ, 成交量442，成交价14.32\n",
      "2022-12-13, 卖出300594.SZ, 成交量-562，成交价20.85\n",
      "2022-12-13, 买入300126.SZ, 成交量2832，成交价22.52\n",
      "2023-02-01, 卖出300126.SZ, 成交量-2832，成交价24.07\n",
      "2023-02-01, 买入300321.SZ, 成交量88，成交价35.42\n",
      "2023-02-01, 买入300637.SZ, 成交量335，成交价14.02\n",
      "2023-02-01, 卖出300521.SZ, 成交量-505，成交价23.74\n",
      "2023-02-01, 买入300594.SZ, 成交量104，成交价21.84\n",
      "2023-02-01, 买入300405.SZ, 成交量3151，成交价21.64\n",
      "最终资金: 402414.95\n",
      "夏普比率: OrderedDict([('sharperatio', 0.8314224682188022)])\n",
      "回撤指标: AutoOrderedDict([('len', 0), ('drawdown', 0.0), ('moneydown', 0.0), ('max', AutoOrderedDict([('len', 219), ('drawdown', 34.536602216959864), ('moneydown', 111608.71710660006)]))])\n"
     ]
    }
   ],
   "source": [
    "start=datetime(2018,2,22)\n",
    "end=datetime(2023,2,10)\n",
    "cash_value={}\n",
    "result=huice_run_num(start,end,stock_list,my_strategy_date_2)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8b501179",
   "metadata": {},
   "source": [
    "### 实现因子数量及其权重的任意定制"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "c77ae41a",
   "metadata": {},
   "outputs": [],
   "source": [
    "buy_date={}\n",
    "sell_date={}\n",
    "postion=set([])\n",
    "stock_list=set([])\n",
    "stock_columns={'总市值(万元)':[True,0.9],'市盈率(静态)':[False,1],'换手率(%)':[True,0.3]}\n",
    "#stock_columns={'总市值(万元)':[True,0.8],'市盈率(静态)':[False,1]}\n",
    "for i in range(0,len(time_id),30):\n",
    "    stock_list_tem=stock_daily[(stock_daily[\"date\"]==time_id[i+1])&(stock_daily[\"open\"]!=stock_daily[\"close\"])][\"股票代码\"].unique()\n",
    "    \n",
    "    stock_list_tem_0=stock_daily[(stock_daily[\"date\"]==time_id[i])&(stock_daily[\"股票代码\"].isin(stock_list_tem))]\n",
    "    columns_list=list(stock_columns.keys())\n",
    "    factor1_stock=stock_list_tem_0.sort_values(by=columns_list[0],ascending=stock_columns[columns_list[0]][0])[\"股票代码\"].tolist()\n",
    "    f_1_df=pd.Series(range(1,len(factor1_stock)+1),index=factor1_stock)*stock_columns[columns_list[0]][1]\n",
    "    for j in columns_list[1:]:\n",
    "        factor1_stock=stock_list_tem_0.sort_values(by=j,ascending=stock_columns[j][0])[\"股票代码\"].tolist()\n",
    "        f_1_df=f_1_df+pd.Series(range(1,len(factor1_stock)+1),index=factor1_stock)*stock_columns[j][1]\n",
    "    \n",
    "    buy_list=f_1_df.sort_values().head(5).index.tolist()\n",
    "    buy_date.update({str(time_id[i].date()):buy_list})\n",
    "    sell_date.update({str(time_id[i].date()):list(postion-set(buy_list))})\n",
    "    postion=set(buy_list)\n",
    "    stock_list=stock_list|postion"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "2bbacfcc",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "总市值(万元)\n",
      "市盈率(静态)\n"
     ]
    }
   ],
   "source": [
    "stock_columns={'总市值(万元)':[True,1],'市盈率(静态)':[False,1]}\n",
    "\n",
    "columns_list=list(stock_columns.keys())\n",
    "factor1_stock=stock_list_tem_0.sort_values(by=columns_list[0],ascending=stock_columns[columns_list[0]][0])[\"股票代码\"].tolist()\n",
    "f_1_df=pd.Series(range(1,len(factor1_stock)+1),index=factor1_stock)\n",
    "for i in columns_list[1:]:\n",
    "    factor1_stock=stock_list_tem_0.sort_values(by=i,ascending=stock_columns[i][0])[\"股票代码\"].tolist()\n",
    "    f_1_df=f_1_df+pd.Series(range(1,len(factor1_stock)+1),index=factor1_stock)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "6bdebdf9",
   "metadata": {},
   "outputs": [],
   "source": [
    "#stock_daily.isnull().sum()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "7ea45344",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2018-02-22 2023-02-10\n",
      "初始资金: 100000.00\n",
      "2018-04-04, 买入300126.SZ, 成交量746，成交价24.04\n",
      "2018-04-04, 买入300092.SZ, 成交量939，成交价19.34\n",
      "2018-04-04, 买入300313.SZ, 成交量864，成交价21.38\n",
      "2018-04-04, 买入300211.SZ, 成交量426，成交价42.51\n",
      "2018-04-04, 买入300483.SZ, 成交量508，成交价35.46\n",
      "2018-05-22, 卖出300092.SZ, 成交量-939，成交价20.01\n",
      "2018-05-22, 卖出300313.SZ, 成交量-864，成交价22.54\n",
      "2018-05-22, 卖出300483.SZ, 成交量-508，成交价39.04\n",
      "2018-05-22, 买入300330.SZ, 成交量814，成交价22.84\n",
      "2018-05-22, 买入300126.SZ, 成交量54，成交价22.84\n",
      "2018-05-22, 买入300442.SZ, 成交量901，成交价20.48\n",
      "2018-05-22, 买入300211.SZ, 成交量9，成交价42.26\n",
      "2018-05-22, 买入300283.SZ, 成交量568，成交价32.48\n",
      "2018-07-04, 卖出300211.SZ, 成交量-435，成交价34.27\n",
      "2018-07-04, 卖出300283.SZ, 成交量-568，成交价28.17\n",
      "2018-07-04, 买入300126.SZ, 成交量26，成交价19.02\n",
      "2018-07-04, 买入300092.SZ, 成交量975，成交价16.05\n",
      "2018-07-04, 买入300442.SZ, 成交量41，成交价16.71\n",
      "2018-07-04, 卖出300330.SZ, 成交量-17，成交价19.89\n",
      "2018-07-04, 买入300483.SZ, 成交量564，成交价27.86\n",
      "2018-08-15, 卖出300092.SZ, 成交量-975，成交价16.05\n",
      "2018-08-15, 买入300211.SZ, 成交量427，成交价34.78\n",
      "2018-08-15, 买入300330.SZ, 成交量21，成交价18.35\n",
      "2018-08-15, 买入300483.SZ, 成交量62，成交价23.92\n",
      "2018-08-15, 卖出300126.SZ, 成交量-67，成交价19.68\n",
      "2018-08-15, 买入300442.SZ, 成交量19，成交价15.58\n",
      "2018-09-27, 卖出300483.SZ, 成交量-626，成交价27.07\n",
      "2018-09-27, 买入300211.SZ, 成交量23，成交价32.74\n",
      "2018-09-27, 买入300330.SZ, 成交量34，成交价17.31\n",
      "2018-09-27, 买入300126.SZ, 成交量37，成交价18.44\n",
      "2018-09-27, 买入300442.SZ, 成交量22，成交价15.04\n",
      "2018-09-27, 买入300354.SZ, 成交量495，成交价29.75\n",
      "2018-11-15, 卖出300354.SZ, 成交量-495，成交价29.23\n",
      "2018-11-15, 卖出300126.SZ, 成交量-796，成交价20.99\n",
      "2018-11-15, 买入300442.SZ, 成交量47，成交价14.51\n",
      "2018-11-15, 买入300483.SZ, 成交量522，成交价28.53\n",
      "2018-11-15, 买入300211.SZ, 成交量13，成交价31.85\n",
      "2018-11-15, 买入300141.SZ, 成交量476，成交价31.28\n",
      "2018-11-15, 买入300330.SZ, 成交量21，成交价16.88\n",
      "2018-12-27, 卖出300141.SZ, 成交量-476，成交价34.51\n",
      "2018-12-27, 卖出300330.SZ, 成交量-873，成交价15.43\n",
      "2018-12-27, 卖出300483.SZ, 成交量-522，成交价33.14\n",
      "2018-12-27, 卖出300211.SZ, 成交量-463，成交价31.60\n",
      "2018-12-27, 买入300442.SZ, 成交量102，成交价13.25\n",
      "2018-12-27, 买入300268.SZ, 成交量668，成交价22.72\n",
      "2018-12-27, 买入300354.SZ, 成交量562，成交价26.65\n",
      "2018-12-27, 买入300030.SZ, 成交量675，成交价22.25\n",
      "2018-12-27, 买入300092.SZ, 成交量955，成交价15.71\n",
      "2019-02-18, 卖出300092.SZ, 成交量-955，成交价17.60\n",
      "2019-02-18, 卖出300268.SZ, 成交量-668，成交价26.74\n",
      "2019-02-18, 卖出300354.SZ, 成交量-562，成交价28.40\n",
      "2019-02-18, 买入300442.SZ, 成交量100，成交价12.80\n",
      "2019-02-18, 买入300330.SZ, 成交量1014，成交价15.49\n",
      "2019-02-18, 买入300030.SZ, 成交量68，成交价21.19\n",
      "2019-02-18, 买入300483.SZ, 成交量504，成交价31.06\n",
      "2019-02-18, 买入300489.SZ, 成交量647，成交价24.26\n",
      "2019-04-01, 卖出300030.SZ, 成交量-743，成交价26.14\n",
      "2019-04-01, 卖出300489.SZ, 成交量-647，成交价30.93\n",
      "2019-04-01, 卖出300483.SZ, 成交量-504，成交价34.94\n",
      "2019-04-01, 买入300268.SZ, 成交量605，成交价31.24\n",
      "2019-04-01, 卖出300330.SZ, 成交量-89，成交价20.46\n",
      "2019-04-01, 买入300442.SZ, 成交量31，成交价15.01\n",
      "2019-04-01, 买入300277.SZ, 成交量488，成交价38.69\n",
      "2019-04-01, 买入300105.SZ, 成交量651，成交价29.12\n",
      "2019-05-17, 卖出300268.SZ, 成交量-605，成交价30.71\n",
      "2019-05-17, 卖出300330.SZ, 成交量-925，成交价18.85\n",
      "2019-05-17, 卖出300442.SZ, 成交量-1263，成交价14.30\n",
      "2019-05-17, 买入300489.SZ, 成交量523，成交价34.06\n",
      "2019-05-17, 买入300092.SZ, 成交量899，成交价19.83\n",
      "2019-05-17, 买入300105.SZ, 成交量14，成交价27.16\n",
      "2019-05-17, 买入300277.SZ, 成交量2，成交价36.55\n",
      "2019-05-17, 买入300629.SZ, 成交量663，成交价26.90\n",
      "2019-07-01, 卖出300092.SZ, 成交量-899，成交价19.65\n",
      "2019-07-01, 卖出300105.SZ, 成交量-665，成交价33.45\n",
      "2019-07-01, 卖出300277.SZ, 成交量-490，成交价37.35\n",
      "2019-07-01, 卖出300629.SZ, 成交量-663，成交价36.23\n",
      "2019-07-01, 买入300141.SZ, 成交量583，成交价33.95\n",
      "2019-07-01, 买入300093.SZ, 成交量1457，成交价13.65\n",
      "2019-07-01, 买入300254.SZ, 成交量1670，成交价11.88\n",
      "2019-07-01, 买入300489.SZ, 成交量44，成交价34.94\n",
      "2019-07-01, 买入300551.SZ, 成交量866，成交价22.82\n",
      "2019-08-12, 卖出300093.SZ, 成交量-1457，成交价14.77\n",
      "2019-08-12, 卖出300551.SZ, 成交量-866，成交价26.12\n",
      "2019-08-12, 买入300489.SZ, 成交量16，成交价33.86\n",
      "2019-08-12, 买入300141.SZ, 成交量102，成交价28.69\n",
      "2019-08-12, 买入300254.SZ, 成交量108，成交价11.10\n",
      "2019-08-12, 买入300264.SZ, 成交量1034，成交价19.34\n",
      "2019-08-12, 买入300277.SZ, 成交量581，成交价33.66\n",
      "2019-09-24, 卖出300277.SZ, 成交量-581，成交价37.66\n",
      "2019-09-24, 卖出300264.SZ, 成交量-1034，成交价23.93\n",
      "2019-09-24, 买入300092.SZ, 成交量1213，成交价18.45\n",
      "2019-09-24, 卖出300489.SZ, 成交量-5，成交价38.47\n",
      "2019-09-24, 买入300254.SZ, 成交量34，成交价12.36\n",
      "2019-09-24, 买入300141.SZ, 成交量11，成交价31.93\n",
      "2019-09-24, 买入300105.SZ, 成交量807，成交价27.58\n",
      "2019-11-12, 卖出300105.SZ, 成交量-807，成交价24.55\n",
      "2019-11-12, 买入300489.SZ, 成交量9，成交价35.10\n",
      "2019-11-12, 卖出300092.SZ, 成交量-28，成交价17.55\n",
      "2019-11-12, 卖出300254.SZ, 成交量-1，成交价11.40\n",
      "2019-11-12, 买入300334.SZ, 成交量1345，成交价15.47\n",
      "2019-12-24, 卖出300334.SZ, 成交量-1345，成交价15.70\n",
      "2019-12-24, 卖出300489.SZ, 成交量-32，成交价38.49\n",
      "2019-12-24, 买入300254.SZ, 成交量6，成交价11.67\n",
      "2019-12-24, 卖出300092.SZ, 成交量-14，成交价18.14\n",
      "2019-12-24, 买入300141.SZ, 成交量24，成交价29.58\n",
      "2019-12-24, 买入300105.SZ, 成交量852，成交价25.15\n",
      "2020-02-13, 卖出300489.SZ, 成交量-555，成交价47.08\n",
      "2020-02-13, 卖出300254.SZ, 成交量-1817，成交价13.31\n",
      "2020-02-13, 买入300092.SZ, 成交量159，成交价16.81\n",
      "2020-02-13, 买入300539.SZ, 成交量1500，成交价14.90\n",
      "2020-02-13, 买入300141.SZ, 成交量20，成交价29.96\n",
      "2020-02-13, 买入300334.SZ, 成交量1651，成交价13.54\n",
      "2020-02-13, 买入300105.SZ, 成交量46，成交价24.85\n",
      "2020-03-26, 卖出300539.SZ, 成交量-1500，成交价15.57\n",
      "2020-03-26, 卖出300092.SZ, 成交量-1330，成交价19.55\n",
      "2020-03-26, 卖出300105.SZ, 成交量-898，成交价29.54\n",
      "2020-03-26, 卖出300334.SZ, 成交量-1651，成交价15.58\n",
      "2020-03-26, 卖出300141.SZ, 成交量-740，成交价53.91\n",
      "2020-03-26, 买入300254.SZ, 成交量2315，成交价11.67\n",
      "2020-03-26, 买入300518.SZ, 成交量1267，成交价21.31\n",
      "2020-03-26, 买入300402.SZ, 成交量3182，成交价8.51\n",
      "2020-03-26, 买入300022.SZ, 成交量1689，成交价16.09\n",
      "2020-03-26, 买入300211.SZ, 成交量577，成交价46.58\n",
      "2020-05-13, 卖出300022.SZ, 成交量-1689，成交价21.81\n",
      "2020-05-13, 卖出300518.SZ, 成交量-1267，成交价22.51\n",
      "2020-05-13, 卖出300402.SZ, 成交量-3182，成交价8.50\n",
      "2020-05-13, 卖出300211.SZ, 成交量-577，成交价46.52\n",
      "2020-05-13, 买入300254.SZ, 成交量525，成交价9.99\n",
      "2020-05-13, 买入300330.SZ, 成交量1495，成交价19.05\n",
      "2020-05-13, 买入300557.SZ, 成交量1080，成交价25.99\n",
      "2020-05-13, 买入300539.SZ, 成交量1913，成交价14.79\n",
      "2020-05-13, 买入300442.SZ, 成交量1816，成交价15.63\n",
      "2020-06-24, 卖出300539.SZ, 成交量-1913，成交价15.50\n",
      "2020-06-24, 卖出300330.SZ, 成交量-1495，成交价22.60\n",
      "2020-06-24, 卖出300442.SZ, 成交量-1816，成交价18.52\n",
      "2020-06-24, 卖出300557.SZ, 成交量-1080，成交价29.62\n",
      "2020-06-24, 买入300153.SZ, 成交量1408，成交价22.44\n",
      "2020-06-24, 买入300254.SZ, 成交量278，成交价10.16\n",
      "2020-06-24, 买入300211.SZ, 成交量741，成交价42.76\n",
      "2020-06-24, 买入300152.SZ, 成交量1993，成交价15.91\n",
      "2020-06-24, 买入300405.SZ, 成交量1896，成交价16.73\n",
      "2020-08-07, 卖出300405.SZ, 成交量-1896，成交价19.67\n",
      "2020-08-07, 卖出300254.SZ, 成交量-3118，成交价11.68\n",
      "2020-08-07, 买入300153.SZ, 成交量38，成交价24.48\n",
      "2020-08-07, 买入300539.SZ, 成交量2063，成交价17.01\n",
      "2020-08-07, 买入300211.SZ, 成交量22，成交价46.28\n",
      "2020-08-07, 买入300126.SZ, 成交量1374，成交价25.78\n",
      "2020-08-07, 卖出300152.SZ, 成交量-4，成交价17.63\n",
      "2020-09-18, 卖出300539.SZ, 成交量-2063，成交价20.90\n",
      "2020-09-18, 卖出300152.SZ, 成交量-1989，成交价32.09\n",
      "2020-09-18, 卖出300126.SZ, 成交量-1374，成交价29.65\n",
      "2020-09-18, 买入300557.SZ, 成交量1418，成交价31.66\n",
      "2020-09-18, 买入300211.SZ, 成交量110，成交价50.71\n",
      "2020-09-18, 买入300592.SZ, 成交量2041，成交价22.23\n",
      "2020-09-18, 买入300153.SZ, 成交量54，成交价29.50\n",
      "2020-09-18, 买入300698.SZ, 成交量2469，成交价18.20\n",
      "2020-11-09, 卖出300153.SZ, 成交量-1500，成交价46.77\n",
      "2020-11-09, 卖出300698.SZ, 成交量-2469，成交价20.99\n",
      "2020-11-09, 卖出300557.SZ, 成交量-1418，成交价37.50\n",
      "2020-11-09, 买入300254.SZ, 成交量3951，成交价12.94\n",
      "2020-11-09, 买入300528.SZ, 成交量5827，成交价8.81\n",
      "2020-11-09, 买入300330.SZ, 成交量1956，成交价26.65\n",
      "2020-11-09, 买入300211.SZ, 成交量70，成交价54.56\n",
      "2020-11-09, 买入300592.SZ, 成交量613，成交价19.15\n",
      "2020-12-21, 卖出300592.SZ, 成交量-2654，成交价17.92\n",
      "2020-12-21, 买入300211.SZ, 成交量77，成交价41.98\n",
      "2020-12-21, 买入300254.SZ, 成交量279，成交价10.49\n",
      "2020-12-21, 买入300330.SZ, 成交量46，成交价22.23\n",
      "2020-12-21, 买入300557.SZ, 成交量1519，成交价29.20\n",
      "2020-12-21, 卖出300528.SZ, 成交量-206，成交价7.88\n",
      "2021-02-02, 卖出300211.SZ, 成交量-1020，成交价55.79\n",
      "2021-02-02, 卖出300528.SZ, 成交量-5621，成交价7.28\n",
      "2021-02-02, 买入300330.SZ, 成交量283，成交价17.86\n",
      "2021-02-02, 买入300254.SZ, 成交量974，成交价7.96\n",
      "2021-02-02, 买入300153.SZ, 成交量1847，成交价22.12\n",
      "2021-02-02, 买入300557.SZ, 成交量236，成交价23.41\n",
      "2021-02-02, 买入300521.SZ, 成交量1351，成交价30.33\n",
      "2021-03-23, 卖出300153.SZ, 成交量-1847，成交价25.26\n",
      "2021-03-23, 卖出300254.SZ, 成交量-284，成交价8.98\n",
      "2021-03-23, 卖出300330.SZ, 成交量-13，成交价19.46\n",
      "2021-03-23, 买入300698.SZ, 成交量2892，成交价15.22\n",
      "2021-03-23, 卖出300557.SZ, 成交量-68，成交价26.22\n",
      "2021-03-23, 买入300521.SZ, 成交量131，成交价29.38\n",
      "2021-05-10, 卖出300521.SZ, 成交量-1482，成交价36.37\n",
      "2021-05-10, 卖出300557.SZ, 成交量-1687，成交价24.33\n",
      "2021-05-10, 卖出300698.SZ, 成交量-2892，成交价16.67\n",
      "2021-05-10, 卖出300254.SZ, 成交量-4920，成交价10.22\n",
      "2021-05-10, 买入300330.SZ, 成交量237，成交价18.77\n",
      "2021-05-10, 买入300479.SZ, 成交量2280，成交价20.69\n",
      "2021-05-10, 买入300700.SZ, 成交量3187，成交价14.69\n",
      "2021-05-10, 买入300615.SZ, 成交量2052，成交价22.86\n",
      "2021-05-10, 买入300688.SZ, 成交量1980，成交价23.73\n",
      "2021-06-22, 卖出300330.SZ, 成交量-2509，成交价23.14\n",
      "2021-06-22, 卖出300615.SZ, 成交量-2052，成交价32.41\n",
      "2021-06-22, 卖出300479.SZ, 成交量-2280，成交价26.90\n",
      "2021-06-22, 买入300534.SZ, 成交量2707，成交价21.29\n",
      "2021-06-22, 买入300688.SZ, 成交量140，成交价27.37\n",
      "2021-06-22, 买入300700.SZ, 成交量99，成交价17.61\n",
      "2021-06-22, 买入300557.SZ, 成交量2096，成交价27.34\n",
      "2021-06-22, 买入300836.SZ, 成交量1581，成交价36.77\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2021-08-03, 卖出300836.SZ, 成交量-1581，成交价37.40\n",
      "2021-08-03, 卖出300534.SZ, 成交量-2707，成交价23.58\n",
      "2021-08-03, 买入300688.SZ, 成交量276，成交价24.93\n",
      "2021-08-03, 买入300313.SZ, 成交量4717，成交价12.47\n",
      "2021-08-03, 买入300330.SZ, 成交量2548，成交价23.06\n",
      "2021-08-03, 卖出300700.SZ, 成交量-97，成交价18.62\n",
      "2021-08-03, 卖出300557.SZ, 成交量-54，成交价28.57\n",
      "2021-09-14, 卖出300313.SZ, 成交量-4717，成交价20.53\n",
      "2021-09-14, 卖出300688.SZ, 成交量-2396，成交价43.73\n",
      "2021-09-14, 卖出300700.SZ, 成交量-3189，成交价18.66\n",
      "2021-09-14, 买入300555.SZ, 成交量3310，成交价22.28\n",
      "2021-09-14, 买入300330.SZ, 成交量749，成交价22.56\n",
      "2021-09-14, 买入300557.SZ, 成交量466，成交价29.52\n",
      "2021-09-14, 买入300086.SZ, 成交量2824，成交价26.09\n",
      "2021-09-14, 买入300836.SZ, 成交量2028，成交价36.39\n",
      "2021-11-04, 卖出300836.SZ, 成交量-2028，成交价31.45\n",
      "2021-11-04, 卖出300557.SZ, 成交量-2508，成交价26.31\n",
      "2021-11-04, 卖出300086.SZ, 成交量-2824，成交价23.73\n",
      "2021-11-04, 买入300534.SZ, 成交量3465，成交价19.18\n",
      "2021-11-04, 买入300330.SZ, 成交量92，成交价19.44\n",
      "2021-11-04, 买入300555.SZ, 成交量45，成交价19.88\n",
      "2021-11-04, 买入300807.SZ, 成交量2925，成交价22.80\n",
      "2021-11-04, 买入300345.SZ, 成交量3067，成交价21.67\n",
      "2021-12-16, 卖出300807.SZ, 成交量-2925，成交价32.41\n",
      "2021-12-16, 卖出300345.SZ, 成交量-3067，成交价23.09\n",
      "2021-12-16, 买入300330.SZ, 成交量326，成交价20.50\n",
      "2021-12-16, 买入300700.SZ, 成交量4203，成交价18.31\n",
      "2021-12-16, 买入300086.SZ, 成交量3034，成交价25.15\n",
      "2021-12-16, 卖出300555.SZ, 成交量-30，成交价22.98\n",
      "2021-12-16, 买入300534.SZ, 成交量46，成交价21.64\n",
      "2022-01-28, 卖出300330.SZ, 成交量-3715，成交价19.68\n",
      "2022-01-28, 卖出300086.SZ, 成交量-3034，成交价30.76\n",
      "2022-01-28, 卖出300555.SZ, 成交量-3325，成交价20.87\n",
      "2022-01-28, 卖出300700.SZ, 成交量-4203，成交价23.03\n",
      "2022-01-28, 卖出300534.SZ, 成交量-3511，成交价36.70\n",
      "2022-01-28, 买入300345.SZ, 成交量4434，成交价21.02\n",
      "2022-01-28, 买入300313.SZ, 成交量7131，成交价12.81\n",
      "2022-01-28, 买入300135.SZ, 成交量2912，成交价31.22\n",
      "2022-01-28, 买入300557.SZ, 成交量3218，成交价28.23\n",
      "2022-01-28, 买入300615.SZ, 成交量3366，成交价27.13\n",
      "2022-03-18, 卖出300135.SZ, 成交量-2912，成交价35.79\n",
      "2022-03-18, 卖出300615.SZ, 成交量-3366，成交价25.74\n",
      "2022-03-18, 卖出300557.SZ, 成交量-3218，成交价33.54\n",
      "2022-03-18, 买入300313.SZ, 成交量448，成交价12.71\n",
      "2022-03-18, 买入300126.SZ, 成交量4020，成交价23.84\n",
      "2022-03-18, 买入300555.SZ, 成交量4634，成交价20.56\n",
      "2022-03-18, 卖出300345.SZ, 成交量-250，成交价23.09\n",
      "2022-03-18, 买入300176.SZ, 成交量3849，成交价24.86\n",
      "2022-05-06, 卖出300313.SZ, 成交量-7579，成交价10.03\n",
      "2022-05-06, 卖出300176.SZ, 成交量-3849，成交价19.52\n",
      "2022-05-06, 卖出300555.SZ, 成交量-4634，成交价17.66\n",
      "2022-05-06, 卖出300345.SZ, 成交量-4184，成交价19.73\n",
      "2022-05-06, 买入300321.SZ, 成交量2603，成交价30.47\n",
      "2022-05-06, 买入300594.SZ, 成交量5598，成交价14.33\n",
      "2022-05-06, 买入300637.SZ, 成交量6306，成交价12.79\n",
      "2022-05-06, 买入300126.SZ, 成交量27，成交价19.77\n",
      "2022-05-06, 买入300808.SZ, 成交量8062，成交价9.95\n",
      "2022-06-20, 卖出300808.SZ, 成交量-8062，成交价13.07\n",
      "2022-06-20, 卖出300594.SZ, 成交量-5598，成交价16.72\n",
      "2022-06-20, 买入300321.SZ, 成交量87，成交价34.85\n",
      "2022-06-20, 买入300736.SZ, 成交量3836，成交价23.97\n",
      "2022-06-20, 买入300637.SZ, 成交量207，成交价14.12\n",
      "2022-06-20, 买入300126.SZ, 成交量143，成交价21.91\n",
      "2022-06-20, 买入300521.SZ, 成交量4632，成交价19.85\n",
      "2022-08-01, 卖出300521.SZ, 成交量-4632，成交价23.63\n",
      "2022-08-01, 卖出300126.SZ, 成交量-4190，成交价26.05\n",
      "2022-08-01, 买入300321.SZ, 成交量102，成交价36.73\n",
      "2022-08-01, 买入300736.SZ, 成交量161，成交价25.38\n",
      "2022-08-01, 卖出300637.SZ, 成交量-73，成交价15.78\n",
      "2022-08-01, 买入300779.SZ, 成交量6823，成交价15.00\n",
      "2022-08-01, 买入300380.SZ, 成交量3415，成交价29.61\n",
      "2022-09-13, 卖出300380.SZ, 成交量-3415，成交价30.21\n",
      "2022-09-13, 卖出300736.SZ, 成交量-3997，成交价28.70\n",
      "2022-09-13, 买入300321.SZ, 成交量104，成交价36.67\n",
      "2022-09-13, 买入300594.SZ, 成交量6256，成交价16.92\n",
      "2022-09-13, 买入300637.SZ, 成交量521，成交价15.13\n",
      "2022-09-13, 卖出300779.SZ, 成交量-229，成交价16.13\n",
      "2022-09-13, 买入300417.SZ, 成交量2702，成交价39.53\n",
      "2022-11-01, 卖出300417.SZ, 成交量-2702，成交价38.32\n",
      "2022-11-01, 买入300321.SZ, 成交量149，成交价32.47\n",
      "2022-11-01, 买入300594.SZ, 成交量3，成交价15.75\n",
      "2022-11-01, 买入300637.SZ, 成交量131，成交价13.90\n",
      "2022-11-01, 买入300736.SZ, 成交量3517，成交价28.29\n",
      "2022-11-01, 卖出300779.SZ, 成交量-151，成交价15.62\n",
      "2022-12-13, 卖出300594.SZ, 成交量-6259，成交价20.85\n",
      "2022-12-13, 卖出300736.SZ, 成交量-3517，成交价37.85\n",
      "2022-12-13, 卖出300779.SZ, 成交量-6443，成交价35.92\n",
      "2022-12-13, 买入300321.SZ, 成交量882，成交价34.74\n",
      "2022-12-13, 买入300637.SZ, 成交量2493，成交价14.32\n",
      "2022-12-13, 买入300126.SZ, 成交量6030，成交价22.52\n",
      "2022-12-13, 买入300665.SZ, 成交量7448，成交价18.37\n",
      "2022-12-13, 买入300399.SZ, 成交量5163，成交价26.52\n",
      "2023-02-01, 卖出300399.SZ, 成交量-5163，成交价28.61\n",
      "2023-02-01, 卖出300665.SZ, 成交量-7448，成交价17.94\n",
      "2023-02-01, 卖出300126.SZ, 成交量-6030，成交价24.07\n",
      "2023-02-01, 买入300321.SZ, 成交量2，成交价35.42\n",
      "2023-02-01, 买入300637.SZ, 成交量252，成交价14.02\n",
      "2023-02-01, 买入300808.SZ, 成交量9919，成交价13.99\n",
      "2023-02-01, 买入300478.SZ, 成交量7244，成交价19.19\n",
      "2023-02-01, 买入300405.SZ, 成交量6408，成交价21.64\n",
      "最终资金: 804258.34\n",
      "夏普比率: OrderedDict([('sharperatio', 0.9485613191496154)])\n",
      "回撤指标: AutoOrderedDict([('len', 0), ('drawdown', 0.0), ('moneydown', 0.0), ('max', AutoOrderedDict([('len', 194), ('drawdown', 35.29363752651681), ('moneydown', 177157.84450660006)]))])\n"
     ]
    }
   ],
   "source": [
    "start=datetime(2018,2,22)\n",
    "end=datetime(2023,2,10)\n",
    "cash_value={}\n",
    "result=huice_run_num(start,end,stock_list,my_strategy_date_2)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "77e2b4c3",
   "metadata": {},
   "source": [
    "### 加入基于财务指标因子的排序"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "9cf8daaa",
   "metadata": {},
   "outputs": [],
   "source": [
    "cwzbsj=pd.read_sql(\"select * from cwzbsj where 股票代码>'003000.SZ'\",con=conn)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "a5977329",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>index</th>\n",
       "      <th>股票代码</th>\n",
       "      <th>公告日期</th>\n",
       "      <th>报告期</th>\n",
       "      <th>基本每股收益</th>\n",
       "      <th>稀释每股收益</th>\n",
       "      <th>每股营业总收入</th>\n",
       "      <th>每股营业收入</th>\n",
       "      <th>每股资本公积</th>\n",
       "      <th>每股盈余公积</th>\n",
       "      <th>...</th>\n",
       "      <th>营业收入环比增长率(%)(单季度)</th>\n",
       "      <th>营业利润同比增长率(%)(单季度)</th>\n",
       "      <th>营业利润环比增长率(%)(单季度)</th>\n",
       "      <th>净利润同比增长率(%)(单季度)</th>\n",
       "      <th>净利润环比增长率(%)(单季度)</th>\n",
       "      <th>归属母公司股东的净利润同比增长率(%)(单季度)</th>\n",
       "      <th>归属母公司股东的净利润环比增长率(%)(单季度)</th>\n",
       "      <th>净资产同比增长率</th>\n",
       "      <th>研发费用</th>\n",
       "      <th>更新标识</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>8</td>\n",
       "      <td>003001.SZ</td>\n",
       "      <td>20200825</td>\n",
       "      <td>20181231</td>\n",
       "      <td>1.32</td>\n",
       "      <td>1.32</td>\n",
       "      <td>10.4098</td>\n",
       "      <td>10.4098</td>\n",
       "      <td>1.7037</td>\n",
       "      <td>0.2874</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>54.6643</td>\n",
       "      <td>27951102.01</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>9</td>\n",
       "      <td>003001.SZ</td>\n",
       "      <td>20200825</td>\n",
       "      <td>20190630</td>\n",
       "      <td>0.84</td>\n",
       "      <td>0.84</td>\n",
       "      <td>6.1807</td>\n",
       "      <td>6.1807</td>\n",
       "      <td>1.6284</td>\n",
       "      <td>0.3492</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>15109126.17</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>10</td>\n",
       "      <td>003001.SZ</td>\n",
       "      <td>20201028</td>\n",
       "      <td>20190930</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>None</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>11</td>\n",
       "      <td>003001.SZ</td>\n",
       "      <td>20200825</td>\n",
       "      <td>20191231</td>\n",
       "      <td>1.76</td>\n",
       "      <td>1.76</td>\n",
       "      <td>14.0454</td>\n",
       "      <td>14.0454</td>\n",
       "      <td>1.7037</td>\n",
       "      <td>0.4646</td>\n",
       "      <td>...</td>\n",
       "      <td>37.7034</td>\n",
       "      <td>NaN</td>\n",
       "      <td>92.6954</td>\n",
       "      <td>NaN</td>\n",
       "      <td>99.9105</td>\n",
       "      <td>NaN</td>\n",
       "      <td>99.9707</td>\n",
       "      <td>30.7962</td>\n",
       "      <td>33452372.49</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>12</td>\n",
       "      <td>003001.SZ</td>\n",
       "      <td>20210415</td>\n",
       "      <td>20200331</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>-68.3178</td>\n",
       "      <td>NaN</td>\n",
       "      <td>-72.3527</td>\n",
       "      <td>NaN</td>\n",
       "      <td>-72.2250</td>\n",
       "      <td>NaN</td>\n",
       "      <td>-71.7480</td>\n",
       "      <td>NaN</td>\n",
       "      <td>None</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 168 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "   index       股票代码      公告日期       报告期  基本每股收益  稀释每股收益  每股营业总收入   每股营业收入  \\\n",
       "0      8  003001.SZ  20200825  20181231    1.32    1.32  10.4098  10.4098   \n",
       "1      9  003001.SZ  20200825  20190630    0.84    0.84   6.1807   6.1807   \n",
       "2     10  003001.SZ  20201028  20190930     NaN     NaN      NaN      NaN   \n",
       "3     11  003001.SZ  20200825  20191231    1.76    1.76  14.0454  14.0454   \n",
       "4     12  003001.SZ  20210415  20200331     NaN     NaN      NaN      NaN   \n",
       "\n",
       "   每股资本公积  每股盈余公积  ...  营业收入环比增长率(%)(单季度) 营业利润同比增长率(%)(单季度) 营业利润环比增长率(%)(单季度)  \\\n",
       "0  1.7037  0.2874  ...                NaN               NaN               NaN   \n",
       "1  1.6284  0.3492  ...                NaN               NaN               NaN   \n",
       "2     NaN     NaN  ...                NaN               NaN               NaN   \n",
       "3  1.7037  0.4646  ...            37.7034               NaN           92.6954   \n",
       "4     NaN     NaN  ...           -68.3178               NaN          -72.3527   \n",
       "\n",
       "  净利润同比增长率(%)(单季度)  净利润环比增长率(%)(单季度)  归属母公司股东的净利润同比增长率(%)(单季度)  \\\n",
       "0              NaN               NaN                       NaN   \n",
       "1              NaN               NaN                       NaN   \n",
       "2              NaN               NaN                       NaN   \n",
       "3              NaN           99.9105                       NaN   \n",
       "4              NaN          -72.2250                       NaN   \n",
       "\n",
       "   归属母公司股东的净利润环比增长率(%)(单季度)  净资产同比增长率         研发费用  更新标识  \n",
       "0                       NaN   54.6643  27951102.01     1  \n",
       "1                       NaN       NaN  15109126.17     1  \n",
       "2                       NaN       NaN         None     1  \n",
       "3                   99.9707   30.7962  33452372.49     1  \n",
       "4                  -71.7480       NaN         None     1  \n",
       "\n",
       "[5 rows x 168 columns]"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cwzbsj.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ce586615",
   "metadata": {},
   "outputs": [],
   "source": [
    "20200825.06"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "id": "78d7c050",
   "metadata": {},
   "outputs": [],
   "source": [
    "#cwzbsj[\"公告日期\"].astype(\"datetime64\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "52247c98",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\wp\\AppData\\Local\\Temp\\ipykernel_3232\\2089892371.py:1: FutureWarning: The default value of regex will change from True to False in a future version.\n",
      "  cwzbsj[\"公告日期\"]=cwzbsj[\"公告日期\"].str.replace(\"\\.0\",\"\")\n"
     ]
    }
   ],
   "source": [
    "cwzbsj[\"公告日期\"]=cwzbsj[\"公告日期\"].str.replace(\"\\.0\",\"\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "b6328f8d",
   "metadata": {},
   "outputs": [],
   "source": [
    "cwzbsj[\"公告日期\"]=cwzbsj[\"公告日期\"].astype(\"datetime64\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "e8a6b543",
   "metadata": {},
   "outputs": [],
   "source": [
    "cwzbsj.set_index(\"公告日期\",inplace=True,drop=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "id": "8477ceb0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>index</th>\n",
       "      <th>公告日期</th>\n",
       "      <th>报告期</th>\n",
       "      <th>基本每股收益</th>\n",
       "      <th>稀释每股收益</th>\n",
       "      <th>每股营业总收入</th>\n",
       "      <th>每股营业收入</th>\n",
       "      <th>每股资本公积</th>\n",
       "      <th>每股盈余公积</th>\n",
       "      <th>每股未分配利润</th>\n",
       "      <th>...</th>\n",
       "      <th>营业收入环比增长率(%)(单季度)</th>\n",
       "      <th>营业利润同比增长率(%)(单季度)</th>\n",
       "      <th>营业利润环比增长率(%)(单季度)</th>\n",
       "      <th>净利润同比增长率(%)(单季度)</th>\n",
       "      <th>净利润环比增长率(%)(单季度)</th>\n",
       "      <th>归属母公司股东的净利润同比增长率(%)(单季度)</th>\n",
       "      <th>归属母公司股东的净利润环比增长率(%)(单季度)</th>\n",
       "      <th>净资产同比增长率</th>\n",
       "      <th>研发费用</th>\n",
       "      <th>更新标识</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票代码</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>003001.SZ</th>\n",
       "      <td>18</td>\n",
       "      <td>2021-10-25</td>\n",
       "      <td>20210930</td>\n",
       "      <td>0.5800</td>\n",
       "      <td>0.5800</td>\n",
       "      <td>8.0275</td>\n",
       "      <td>8.0275</td>\n",
       "      <td>5.9565</td>\n",
       "      <td>0.3451</td>\n",
       "      <td>3.1855</td>\n",
       "      <td>...</td>\n",
       "      <td>-17.5238</td>\n",
       "      <td>6.0350</td>\n",
       "      <td>-42.4417</td>\n",
       "      <td>-9.6950</td>\n",
       "      <td>-50.9569</td>\n",
       "      <td>-10.4657</td>\n",
       "      <td>-50.7254</td>\n",
       "      <td>4.5735</td>\n",
       "      <td>38318290.38</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>003002.SZ</th>\n",
       "      <td>17</td>\n",
       "      <td>2021-10-28</td>\n",
       "      <td>20210930</td>\n",
       "      <td>0.3119</td>\n",
       "      <td>0.3119</td>\n",
       "      <td>2.4994</td>\n",
       "      <td>2.4994</td>\n",
       "      <td>1.8807</td>\n",
       "      <td>0.1420</td>\n",
       "      <td>1.8848</td>\n",
       "      <td>...</td>\n",
       "      <td>-6.6426</td>\n",
       "      <td>-45.4537</td>\n",
       "      <td>-69.2336</td>\n",
       "      <td>-52.6661</td>\n",
       "      <td>-74.7931</td>\n",
       "      <td>-51.8338</td>\n",
       "      <td>-74.7550</td>\n",
       "      <td>1.4942</td>\n",
       "      <td>15296164.79</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>003003.SZ</th>\n",
       "      <td>20</td>\n",
       "      <td>2021-10-29</td>\n",
       "      <td>20210930</td>\n",
       "      <td>0.1300</td>\n",
       "      <td>0.1300</td>\n",
       "      <td>5.0766</td>\n",
       "      <td>5.0766</td>\n",
       "      <td>3.8742</td>\n",
       "      <td>0.1734</td>\n",
       "      <td>1.8495</td>\n",
       "      <td>...</td>\n",
       "      <td>1.2257</td>\n",
       "      <td>-79.1216</td>\n",
       "      <td>-73.6094</td>\n",
       "      <td>-95.1382</td>\n",
       "      <td>-93.7357</td>\n",
       "      <td>-93.4627</td>\n",
       "      <td>-92.1307</td>\n",
       "      <td>1.0188</td>\n",
       "      <td>36144660.94</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>003004.SZ</th>\n",
       "      <td>15</td>\n",
       "      <td>2021-10-28</td>\n",
       "      <td>20210930</td>\n",
       "      <td>0.2298</td>\n",
       "      <td>0.2298</td>\n",
       "      <td>1.4573</td>\n",
       "      <td>1.4573</td>\n",
       "      <td>4.4559</td>\n",
       "      <td>0.4343</td>\n",
       "      <td>2.5926</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.6585</td>\n",
       "      <td>32.5156</td>\n",
       "      <td>53.1786</td>\n",
       "      <td>57.4852</td>\n",
       "      <td>10.0640</td>\n",
       "      <td>70.5405</td>\n",
       "      <td>12.6380</td>\n",
       "      <td>148.8917</td>\n",
       "      <td>16628063.69</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>003005.SZ</th>\n",
       "      <td>12</td>\n",
       "      <td>2021-10-28</td>\n",
       "      <td>20210930</td>\n",
       "      <td>0.9717</td>\n",
       "      <td>0.9717</td>\n",
       "      <td>4.3609</td>\n",
       "      <td>4.3609</td>\n",
       "      <td>7.3872</td>\n",
       "      <td>0.2858</td>\n",
       "      <td>4.9104</td>\n",
       "      <td>...</td>\n",
       "      <td>-38.3724</td>\n",
       "      <td>-74.7833</td>\n",
       "      <td>-76.9160</td>\n",
       "      <td>-73.4530</td>\n",
       "      <td>-75.1517</td>\n",
       "      <td>-72.9819</td>\n",
       "      <td>-74.7372</td>\n",
       "      <td>5.4541</td>\n",
       "      <td>34601121.18</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>873169.BJ</th>\n",
       "      <td>13</td>\n",
       "      <td>2021-12-22</td>\n",
       "      <td>20210930</td>\n",
       "      <td>0.4100</td>\n",
       "      <td>0.4100</td>\n",
       "      <td>2.6216</td>\n",
       "      <td>2.6216</td>\n",
       "      <td>0.2994</td>\n",
       "      <td>0.1338</td>\n",
       "      <td>0.9879</td>\n",
       "      <td>...</td>\n",
       "      <td>18.2571</td>\n",
       "      <td>96.2618</td>\n",
       "      <td>38.0811</td>\n",
       "      <td>97.9025</td>\n",
       "      <td>38.0146</td>\n",
       "      <td>97.9025</td>\n",
       "      <td>38.0146</td>\n",
       "      <td>71.3869</td>\n",
       "      <td>5536688.24</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>873223.BJ</th>\n",
       "      <td>13</td>\n",
       "      <td>2021-11-20</td>\n",
       "      <td>20210930</td>\n",
       "      <td>0.1400</td>\n",
       "      <td>0.1400</td>\n",
       "      <td>1.5792</td>\n",
       "      <td>1.5792</td>\n",
       "      <td>0.1146</td>\n",
       "      <td>0.0515</td>\n",
       "      <td>0.4765</td>\n",
       "      <td>...</td>\n",
       "      <td>23.2479</td>\n",
       "      <td>250.0494</td>\n",
       "      <td>92.9384</td>\n",
       "      <td>221.4271</td>\n",
       "      <td>119.7993</td>\n",
       "      <td>298.2389</td>\n",
       "      <td>119.7993</td>\n",
       "      <td>35.5144</td>\n",
       "      <td>8681627.16</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>873305.BJ</th>\n",
       "      <td>0</td>\n",
       "      <td>2021-12-23</td>\n",
       "      <td>20210930</td>\n",
       "      <td>0.6200</td>\n",
       "      <td>0.6200</td>\n",
       "      <td>3.2899</td>\n",
       "      <td>3.2899</td>\n",
       "      <td>1.9070</td>\n",
       "      <td>0.2528</td>\n",
       "      <td>2.0704</td>\n",
       "      <td>...</td>\n",
       "      <td>-16.9018</td>\n",
       "      <td>-63.8275</td>\n",
       "      <td>-61.8179</td>\n",
       "      <td>-56.6824</td>\n",
       "      <td>-58.7780</td>\n",
       "      <td>-56.6824</td>\n",
       "      <td>-58.7780</td>\n",
       "      <td>NaN</td>\n",
       "      <td>6157548.73</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>873339.BJ</th>\n",
       "      <td>0</td>\n",
       "      <td>2021-11-27</td>\n",
       "      <td>20210930</td>\n",
       "      <td>0.3400</td>\n",
       "      <td>NaN</td>\n",
       "      <td>3.3014</td>\n",
       "      <td>3.3014</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0892</td>\n",
       "      <td>0.3115</td>\n",
       "      <td>...</td>\n",
       "      <td>37.6028</td>\n",
       "      <td>102.5549</td>\n",
       "      <td>132.7244</td>\n",
       "      <td>88.7842</td>\n",
       "      <td>89.7479</td>\n",
       "      <td>88.7842</td>\n",
       "      <td>89.7479</td>\n",
       "      <td>-8.9354</td>\n",
       "      <td>19226385.23</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>873527.BJ</th>\n",
       "      <td>0</td>\n",
       "      <td>2021-08-28</td>\n",
       "      <td>20210630</td>\n",
       "      <td>0.2200</td>\n",
       "      <td>0.2200</td>\n",
       "      <td>3.5739</td>\n",
       "      <td>3.5739</td>\n",
       "      <td>1.3959</td>\n",
       "      <td>0.2397</td>\n",
       "      <td>1.5638</td>\n",
       "      <td>...</td>\n",
       "      <td>50.0303</td>\n",
       "      <td>NaN</td>\n",
       "      <td>95.1687</td>\n",
       "      <td>NaN</td>\n",
       "      <td>96.1544</td>\n",
       "      <td>NaN</td>\n",
       "      <td>96.1544</td>\n",
       "      <td>NaN</td>\n",
       "      <td>5344348.99</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>3511 rows × 167 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "           index       公告日期       报告期  基本每股收益  稀释每股收益  每股营业总收入  每股营业收入  \\\n",
       "股票代码                                                                     \n",
       "003001.SZ     18 2021-10-25  20210930  0.5800  0.5800   8.0275  8.0275   \n",
       "003002.SZ     17 2021-10-28  20210930  0.3119  0.3119   2.4994  2.4994   \n",
       "003003.SZ     20 2021-10-29  20210930  0.1300  0.1300   5.0766  5.0766   \n",
       "003004.SZ     15 2021-10-28  20210930  0.2298  0.2298   1.4573  1.4573   \n",
       "003005.SZ     12 2021-10-28  20210930  0.9717  0.9717   4.3609  4.3609   \n",
       "...          ...        ...       ...     ...     ...      ...     ...   \n",
       "873169.BJ     13 2021-12-22  20210930  0.4100  0.4100   2.6216  2.6216   \n",
       "873223.BJ     13 2021-11-20  20210930  0.1400  0.1400   1.5792  1.5792   \n",
       "873305.BJ      0 2021-12-23  20210930  0.6200  0.6200   3.2899  3.2899   \n",
       "873339.BJ      0 2021-11-27  20210930  0.3400     NaN   3.3014  3.3014   \n",
       "873527.BJ      0 2021-08-28  20210630  0.2200  0.2200   3.5739  3.5739   \n",
       "\n",
       "           每股资本公积  每股盈余公积  每股未分配利润  ... 营业收入环比增长率(%)(单季度) 营业利润同比增长率(%)(单季度)  \\\n",
       "股票代码                                ...                                       \n",
       "003001.SZ  5.9565  0.3451   3.1855  ...          -17.5238            6.0350   \n",
       "003002.SZ  1.8807  0.1420   1.8848  ...           -6.6426          -45.4537   \n",
       "003003.SZ  3.8742  0.1734   1.8495  ...            1.2257          -79.1216   \n",
       "003004.SZ  4.4559  0.4343   2.5926  ...           -0.6585           32.5156   \n",
       "003005.SZ  7.3872  0.2858   4.9104  ...          -38.3724          -74.7833   \n",
       "...           ...     ...      ...  ...               ...               ...   \n",
       "873169.BJ  0.2994  0.1338   0.9879  ...           18.2571           96.2618   \n",
       "873223.BJ  0.1146  0.0515   0.4765  ...           23.2479          250.0494   \n",
       "873305.BJ  1.9070  0.2528   2.0704  ...          -16.9018          -63.8275   \n",
       "873339.BJ  0.0000  0.0892   0.3115  ...           37.6028          102.5549   \n",
       "873527.BJ  1.3959  0.2397   1.5638  ...           50.0303               NaN   \n",
       "\n",
       "          营业利润环比增长率(%)(单季度)  净利润同比增长率(%)(单季度)  净利润环比增长率(%)(单季度)  \\\n",
       "股票代码                                                              \n",
       "003001.SZ          -42.4417           -9.6950          -50.9569   \n",
       "003002.SZ          -69.2336          -52.6661          -74.7931   \n",
       "003003.SZ          -73.6094          -95.1382          -93.7357   \n",
       "003004.SZ           53.1786           57.4852           10.0640   \n",
       "003005.SZ          -76.9160          -73.4530          -75.1517   \n",
       "...                     ...               ...               ...   \n",
       "873169.BJ           38.0811           97.9025           38.0146   \n",
       "873223.BJ           92.9384          221.4271          119.7993   \n",
       "873305.BJ          -61.8179          -56.6824          -58.7780   \n",
       "873339.BJ          132.7244           88.7842           89.7479   \n",
       "873527.BJ           95.1687               NaN           96.1544   \n",
       "\n",
       "           归属母公司股东的净利润同比增长率(%)(单季度)  归属母公司股东的净利润环比增长率(%)(单季度)  净资产同比增长率  \\\n",
       "股票代码                                                                      \n",
       "003001.SZ                  -10.4657                  -50.7254    4.5735   \n",
       "003002.SZ                  -51.8338                  -74.7550    1.4942   \n",
       "003003.SZ                  -93.4627                  -92.1307    1.0188   \n",
       "003004.SZ                   70.5405                   12.6380  148.8917   \n",
       "003005.SZ                  -72.9819                  -74.7372    5.4541   \n",
       "...                             ...                       ...       ...   \n",
       "873169.BJ                   97.9025                   38.0146   71.3869   \n",
       "873223.BJ                  298.2389                  119.7993   35.5144   \n",
       "873305.BJ                  -56.6824                  -58.7780       NaN   \n",
       "873339.BJ                   88.7842                   89.7479   -8.9354   \n",
       "873527.BJ                       NaN                   96.1544       NaN   \n",
       "\n",
       "                  研发费用  更新标识  \n",
       "股票代码                          \n",
       "003001.SZ  38318290.38     1  \n",
       "003002.SZ  15296164.79     1  \n",
       "003003.SZ  36144660.94     1  \n",
       "003004.SZ  16628063.69     1  \n",
       "003005.SZ  34601121.18     1  \n",
       "...                ...   ...  \n",
       "873169.BJ   5536688.24     1  \n",
       "873223.BJ   8681627.16     1  \n",
       "873305.BJ   6157548.73     1  \n",
       "873339.BJ  19226385.23     1  \n",
       "873527.BJ   5344348.99     1  \n",
       "\n",
       "[3511 rows x 167 columns]"
      ]
     },
     "execution_count": 72,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cwzbsj[cwzbsj[\"公告日期\"]<time_id[1000]].groupby(\"股票代码\").last()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "id": "6e2812ed",
   "metadata": {},
   "outputs": [],
   "source": [
    "buy_date={}\n",
    "sell_date={}\n",
    "postion=set([])\n",
    "stock_list=set([])\n",
    "stock_columns={'总市值(万元)':[True,0.9],'市盈率(静态)':[False,1],'换手率(%)':[True,0.3]}\n",
    "#stock_columns={'总市值(万元)':[True,0.8],'市盈率(静态)':[False,1]}\n",
    "cw_columns={'营业收入环比增长率(%)(单季度)':[True,0.4]}\n",
    "for i in range(0,len(time_id),30):\n",
    "    stock_list_tem=stock_daily[(stock_daily[\"date\"]==time_id[i+1])&(stock_daily[\"open\"]!=stock_daily[\"close\"])][\"股票代码\"].unique()\n",
    "    \n",
    "    stock_list_tem_0=stock_daily[(stock_daily[\"date\"]==time_id[i])&(stock_daily[\"股票代码\"].isin(stock_list_tem))]\n",
    "    columns_list=list(stock_columns.keys())\n",
    "    factor1_stock=stock_list_tem_0.sort_values(by=columns_list[0],ascending=stock_columns[columns_list[0]][0])[\"股票代码\"].tolist()\n",
    "    f_1_df=pd.Series(range(1,len(factor1_stock)+1),index=factor1_stock)*stock_columns[columns_list[0]][1]\n",
    "    for j in columns_list[1:]:\n",
    "        factor1_stock=stock_list_tem_0.sort_values(by=j,ascending=stock_columns[j][0])[\"股票代码\"].tolist()\n",
    "        f_1_df=f_1_df+pd.Series(range(1,len(factor1_stock)+1),index=factor1_stock)*stock_columns[j][1]\n",
    "    \n",
    "    cw_list_tem_0=cwzbsj[(cwzbsj[\"公告日期\"]<time_id[i])&(cwzbsj[\"股票代码\"].isin(stock_list_tem))].groupby(\"股票代码\").last()\n",
    "    if len(cw_list_tem_0)>0:\n",
    "        for j in cw_columns.keys():\n",
    "            factor1_stock=cw_list_tem_0.sort_values(by=j,ascending=cw_columns[j][0]).index.tolist()\n",
    "            f_1_df=f_1_df+pd.Series(range(1,len(factor1_stock)+1),index=factor1_stock)*cw_columns[j][1]\n",
    "    \n",
    "    buy_list=f_1_df.sort_values().head(5).index.tolist()\n",
    "    buy_date.update({str(time_id[i].date()):buy_list})\n",
    "    sell_date.update({str(time_id[i].date()):list(postion-set(buy_list))})\n",
    "    postion=set(buy_list)\n",
    "    stock_list=stock_list|postion"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 87,
   "id": "68093e2f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array(['index', '股票代码', '公告日期', '报告期', '基本每股收益', '稀释每股收益', '每股营业总收入',\n",
       "       '每股营业收入', '每股资本公积', '每股盈余公积', '每股未分配利润', '非经常性损益',\n",
       "       '扣除非经常性损益后的净利润(扣非净利润)', '毛利', '流动比率', '速动比率', '保守速动比率', '存货周转天数',\n",
       "       '应收账款周转天数', '存货周转率', '应收账款周转率', '流动资产周转率', '固定资产周转率', '总资产周转率',\n",
       "       '经营活动净收益', '价值变动净收益', '利息费用', '折旧与摊销', '息税前利润', '息税折旧摊销前利润',\n",
       "       '企业自由现金流量', '股权自由现金流量', '无息流动负债', '无息非流动负债', '带息债务', '净债务', '有形资产',\n",
       "       '营运资金', '营运流动资本', '全部投入资本', '留存收益', '期末摊薄每股收益', '每股净资产',\n",
       "       '每股经营活动产生的现金流量净额', '每股留存收益', '每股现金流量净额', '每股息税前利润', '每股企业自由现金流量',\n",
       "       '每股股东自由现金流量', '销售净利率', '销售毛利率', '销售成本率', '销售期间费用率', '净利润/营业总收入',\n",
       "       '销售费用/营业总收入', '管理费用/营业总收入', '财务费用/营业总收入', '资产减值损失/营业总收入',\n",
       "       '营业总成本/营业总收入', '营业利润/营业总收入', '息税前利润/营业总收入', '净资产收益率', '加权平均净资产收益率',\n",
       "       '净资产收益率(扣除非经常损益)', '总资产报酬率', '总资产净利润', '投入资本回报率', '年化净资产收益率',\n",
       "       '年化总资产报酬率', '平均净资产收益率(增发条件)', '经营活动净收益/利润总额', '价值变动净收益/利润总额',\n",
       "       '营业外收支净额/利润总额', '所得税/利润总额', '扣除非经常损益后的净利润/净利润',\n",
       "       '销售商品提供劳务收到的现金/营业收入', '经营活动产生的现金流量净额/营业收入',\n",
       "       '经营活动产生的现金流量净额/经营活动净收益', '资本支出/折旧和摊销', '资产负债率', '权益乘数',\n",
       "       '权益乘数(杜邦分析)', '流动资产/总资产', '非流动资产/总资产', '有形资产/总资产', '带息债务/全部投入资本',\n",
       "       '归属于母公司的股东权益/全部投入资本', '流动负债/负债合计', '非流动负债/负债合计',\n",
       "       '经营活动产生的现金流量净额/流动负债', '产权比率', '归属于母公司的股东权益/负债合计',\n",
       "       '归属于母公司的股东权益/带息债务', '有形资产/负债合计', '有形资产/带息债务', '有形资产/净债务',\n",
       "       '经营活动产生的现金流量净额/负债合计', '经营活动产生的现金流量净额/带息债务', '经营活动产生的现金流量净额/净债务',\n",
       "       '已获利息倍数(EBIT/利息费用)', '长期债务与营运资金比率', '息税折旧摊销前利润/负债合计', '营业周期',\n",
       "       '年化总资产净利率', '总资产净利率(杜邦分析)', '固定资产合计', '扣除财务费用前营业利润', '非营业利润',\n",
       "       '营业利润/利润总额', '非营业利润/利润总额', '经营活动产生的现金流量净额/营业利润', '货币资金/流动负债',\n",
       "       '货币资金/带息流动负债', '营业利润/流动负债', '营业利润/负债合计', '年化投入资本回报率', '固定资产合计周转率',\n",
       "       '利润总额/营业收入', '经营活动单季度净收益', '价值变动单季度净收益', '扣除非经常损益后的单季度净利润',\n",
       "       '每股收益(单季度)', '销售净利率(单季度)', '销售毛利率(单季度)', '销售期间费用率(单季度)',\n",
       "       '净利润/营业总收入(单季度)', '销售费用/营业总收入 (单季度)', '管理费用/营业总收入 (单季度)',\n",
       "       '财务费用/营业总收入 (单季度)', '资产减值损失/营业总收入(单季度)', '营业总成本/营业总收入 (单季度)',\n",
       "       '营业利润/营业总收入(单季度)', '净资产收益率(单季度)', '净资产单季度收益率(扣除非经常损益)',\n",
       "       '总资产净利润(单季度)', '经营活动净收益/利润总额(单季度)', '价值变动净收益/利润总额(单季度)',\n",
       "       '扣除非经常损益后的净利润/净利润(单季度)', '销售商品提供劳务收到的现金/营业收入(单季度)',\n",
       "       '经营活动产生的现金流量净额/营业收入(单季度)', '经营活动产生的现金流量净额/经营活动净收益(单季度)',\n",
       "       '基本每股收益同比增长率(%)', '稀释每股收益同比增长率(%)', '每股经营活动产生的现金流量净额同比增长率(%)',\n",
       "       '营业利润同比增长率(%)', '利润总额同比增长率(%)', '归属母公司股东的净利润同比增长率(%)',\n",
       "       '归属母公司股东的净利润-扣除非经常损益同比增长率(%)', '经营活动产生的现金流量净额同比增长率(%)',\n",
       "       '净资产收益率(摊薄)同比增长率(%)', '每股净资产相对年初增长率(%)', '资产总计相对年初增长率(%)',\n",
       "       '归属母公司的股东权益相对年初增长率(%)', '营业总收入同比增长率(%)', '营业收入同比增长率(%)',\n",
       "       '营业总收入同比增长率(%)(单季度)', '营业总收入环比增长率(%)(单季度)', '营业收入同比增长率(%)(单季度)',\n",
       "       '营业收入环比增长率(%)(单季度)', '营业利润同比增长率(%)(单季度)', '营业利润环比增长率(%)(单季度)',\n",
       "       '净利润同比增长率(%)(单季度)', '净利润环比增长率(%)(单季度)', '归属母公司股东的净利润同比增长率(%)(单季度)',\n",
       "       '归属母公司股东的净利润环比增长率(%)(单季度)', '净资产同比增长率', '研发费用', '更新标识'],\n",
       "      dtype=object)"
      ]
     },
     "execution_count": 87,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cwzbsj.columns.values"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "id": "7cdcedb2",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2018-02-22 2023-02-10\n",
      "初始资金: 100000.00\n",
      "2018-04-04, 买入300126.SZ, 成交量746，成交价24.04\n",
      "2018-04-04, 买入300092.SZ, 成交量939，成交价19.34\n",
      "2018-04-04, 买入300313.SZ, 成交量864，成交价21.38\n",
      "2018-04-04, 买入300211.SZ, 成交量426，成交价42.51\n",
      "2018-04-04, 买入300483.SZ, 成交量508，成交价35.46\n",
      "2018-05-22, 卖出300092.SZ, 成交量-939，成交价20.01\n",
      "2018-05-22, 卖出300483.SZ, 成交量-508，成交价39.04\n",
      "2018-05-22, 卖出300211.SZ, 成交量-426，成交价42.26\n",
      "2018-05-22, 卖出300313.SZ, 成交量-864，成交价22.54\n",
      "2018-05-22, 卖出300126.SZ, 成交量-746，成交价22.84\n",
      "2018-05-22, 买入300330.SZ, 成交量814，成交价22.84\n",
      "2018-05-22, 买入300354.SZ, 成交量489，成交价37.70\n",
      "2018-05-22, 买入300402.SZ, 成交量1732，成交价10.74\n",
      "2018-05-22, 买入300105.SZ, 成交量598，成交价30.90\n",
      "2018-05-22, 买入300551.SZ, 成交量703，成交价26.25\n",
      "2018-07-04, 卖出300402.SZ, 成交量-1732，成交价9.22\n",
      "2018-07-04, 卖出300551.SZ, 成交量-703，成交价20.06\n",
      "2018-07-04, 卖出300330.SZ, 成交量-26，成交价19.89\n",
      "2018-07-04, 买入300354.SZ, 成交量2，成交价31.60\n",
      "2018-07-04, 买入300105.SZ, 成交量10，成交价25.56\n",
      "2018-07-04, 买入300092.SZ, 成交量964，成交价16.05\n",
      "2018-07-04, 买入300483.SZ, 成交量558，成交价27.86\n",
      "2018-08-15, 卖出300105.SZ, 成交量-608，成交价25.50\n",
      "2018-08-15, 卖出300354.SZ, 成交量-5，成交价30.51\n",
      "2018-08-15, 买入300330.SZ, 成交量20，成交价18.35\n",
      "2018-08-15, 买入300483.SZ, 成交量60，成交价23.92\n",
      "2018-08-15, 卖出300092.SZ, 成交量-45，成交价16.05\n",
      "2018-08-15, 买入300551.SZ, 成交量783，成交价19.09\n",
      "2018-09-27, 卖出300092.SZ, 成交量-919，成交价19.67\n",
      "2018-09-27, 卖出300330.SZ, 成交量-808，成交价17.31\n",
      "2018-09-27, 卖出300354.SZ, 成交量-486，成交价29.75\n",
      "2018-09-27, 卖出300551.SZ, 成交量-783，成交价17.89\n",
      "2018-09-27, 买入300211.SZ, 成交量469，成交价32.74\n",
      "2018-09-27, 买入300442.SZ, 成交量1024，成交价15.04\n",
      "2018-09-27, 买入300126.SZ, 成交量830，成交价18.44\n",
      "2018-09-27, 卖出300483.SZ, 成交量-51，成交价27.07\n",
      "2018-09-27, 买入300235.SZ, 成交量446，成交价34.53\n",
      "2018-11-15, 卖出300235.SZ, 成交量-446，成交价34.31\n",
      "2018-11-15, 卖出300126.SZ, 成交量-830，成交价20.99\n",
      "2018-11-15, 买入300442.SZ, 成交量60，成交价14.51\n",
      "2018-11-15, 卖出300483.SZ, 成交量-16，成交价28.53\n",
      "2018-11-15, 买入300141.SZ, 成交量502，成交价31.28\n",
      "2018-11-15, 买入300489.SZ, 成交量585，成交价27.05\n",
      "2018-11-15, 买入300211.SZ, 成交量19，成交价31.85\n",
      "2018-12-27, 卖出300141.SZ, 成交量-502，成交价34.51\n",
      "2018-12-27, 卖出300483.SZ, 成交量-551，成交价33.14\n",
      "2018-12-27, 卖出300211.SZ, 成交量-488，成交价31.60\n",
      "2018-12-27, 买入300442.SZ, 成交量109，成交价13.25\n",
      "2018-12-27, 买入300354.SZ, 成交量592，成交价26.65\n",
      "2018-12-27, 买入300489.SZ, 成交量62，成交价24.51\n",
      "2018-12-27, 买入300105.SZ, 成交量686，成交价23.07\n",
      "2018-12-27, 买入300239.SZ, 成交量779，成交价20.22\n",
      "2019-02-18, 卖出300105.SZ, 成交量-686，成交价24.26\n",
      "2019-02-18, 卖出300239.SZ, 成交量-779，成交价22.46\n",
      "2019-02-18, 卖出300354.SZ, 成交量-592，成交价28.40\n",
      "2019-02-18, 买入300442.SZ, 成交量89，成交价12.80\n",
      "2019-02-18, 买入300489.SZ, 成交量26，成交价24.26\n",
      "2019-02-18, 买入300483.SZ, 成交量524，成交价31.06\n",
      "2019-02-18, 买入300330.SZ, 成交量1055，成交价15.49\n",
      "2019-02-18, 买入300030.SZ, 成交量773，成交价21.19\n",
      "2019-04-01, 卖出300030.SZ, 成交量-773，成交价26.14\n",
      "2019-04-01, 卖出300489.SZ, 成交量-673，成交价30.93\n",
      "2019-04-01, 卖出300483.SZ, 成交量-524，成交价34.94\n",
      "2019-04-01, 买入300442.SZ, 成交量28，成交价15.01\n",
      "2019-04-01, 买入300629.SZ, 成交量669，成交价29.74\n",
      "2019-04-01, 买入300354.SZ, 成交量557，成交价35.43\n",
      "2019-04-01, 买入300239.SZ, 成交量753，成交价26.31\n",
      "2019-04-01, 卖出300330.SZ, 成交量-96，成交价20.46\n",
      "2019-05-17, 卖出300239.SZ, 成交量-753，成交价28.67\n",
      "2019-05-17, 卖出300330.SZ, 成交量-959，成交价18.85\n",
      "2019-05-17, 卖出300354.SZ, 成交量-557，成交价36.58\n",
      "2019-05-17, 卖出300442.SZ, 成交量-1310，成交价14.30\n",
      "2019-05-17, 卖出300629.SZ, 成交量-669，成交价26.90\n",
      "2019-05-17, 买入300489.SZ, 成交量553，成交价34.06\n",
      "2019-05-17, 买入300277.SZ, 成交量518，成交价36.55\n",
      "2019-05-17, 买入300105.SZ, 成交量703，成交价27.16\n",
      "2019-05-17, 买入300557.SZ, 成交量696，成交价26.91\n",
      "2019-05-17, 买入300264.SZ, 成交量832，成交价22.82\n",
      "2019-07-01, 卖出300105.SZ, 成交量-703，成交价33.45\n",
      "2019-07-01, 卖出300489.SZ, 成交量-553，成交价34.94\n",
      "2019-07-01, 卖出300557.SZ, 成交量-696，成交价28.68\n",
      "2019-07-01, 买入300551.SZ, 成交量889，成交价22.82\n",
      "2019-07-01, 买入300141.SZ, 成交量598，成交价33.95\n",
      "2019-07-01, 买入300093.SZ, 成交量1496，成交价13.65\n",
      "2019-07-01, 买入300264.SZ, 成交量53，成交价22.98\n",
      "2019-07-01, 买入300277.SZ, 成交量34，成交价37.35\n",
      "2019-08-12, 卖出300093.SZ, 成交量-1496，成交价14.77\n",
      "2019-08-12, 卖出300551.SZ, 成交量-889，成交价26.12\n",
      "2019-08-12, 买入300141.SZ, 成交量82，成交价28.69\n",
      "2019-08-12, 买入300264.SZ, 成交量141，成交价19.34\n",
      "2019-08-12, 买入300277.SZ, 成交量24，成交价33.66\n",
      "2019-08-12, 买入300489.SZ, 成交量578，成交价33.86\n",
      "2019-08-12, 买入300334.SZ, 成交量1295，成交价15.08\n",
      "2019-09-24, 卖出300489.SZ, 成交量-578，成交价38.47\n",
      "2019-09-24, 卖出300264.SZ, 成交量-1026，成交价23.93\n",
      "2019-09-24, 卖出300334.SZ, 成交量-1295，成交价16.67\n",
      "2019-09-24, 卖出300141.SZ, 成交量-680，成交价31.93\n",
      "2019-09-24, 卖出300277.SZ, 成交量-576，成交价37.66\n",
      "2019-09-24, 买入300534.SZ, 成交量1026，成交价21.61\n",
      "2019-09-24, 买入300092.SZ, 成交量1203，成交价18.45\n",
      "2019-09-24, 买入300086.SZ, 成交量879，成交价25.11\n",
      "2019-09-24, 买入300281.SZ, 成交量628，成交价35.55\n",
      "2019-09-24, 买入300254.SZ, 成交量1797，成交价12.36\n",
      "2019-11-12, 卖出300534.SZ, 成交量-1026，成交价19.95\n",
      "2019-11-12, 卖出300254.SZ, 成交量-1797，成交价11.40\n",
      "2019-11-12, 卖出300092.SZ, 成交量-1203，成交价17.55\n",
      "2019-11-12, 卖出300281.SZ, 成交量-628，成交价35.92\n",
      "2019-11-12, 卖出300086.SZ, 成交量-879，成交价22.22\n",
      "2019-11-12, 买入300141.SZ, 成交量701，成交价29.63\n",
      "2019-11-12, 买入300334.SZ, 成交量1358，成交价15.47\n",
      "2019-11-12, 买入300629.SZ, 成交量824，成交价25.27\n",
      "2019-11-12, 买入300539.SZ, 成交量1393，成交价14.95\n",
      "2019-11-12, 买入300553.SZ, 成交量575，成交价35.93\n",
      "2019-12-24, 卖出300629.SZ, 成交量-824，成交价27.85\n",
      "2019-12-24, 买入300141.SZ, 成交量27，成交价29.58\n",
      "2019-12-24, 卖出300539.SZ, 成交量-13，成交价15.57\n",
      "2019-12-24, 买入300553.SZ, 成交量6，成交价37.47\n",
      "2019-12-24, 买入300334.SZ, 成交量10，成交价15.70\n",
      "2019-12-24, 买入300402.SZ, 成交量2375，成交价9.05\n",
      "2020-02-13, 卖出300141.SZ, 成交量-54，成交价29.96\n",
      "2020-02-13, 卖出300539.SZ, 成交量-16，成交价14.90\n",
      "2020-02-13, 买入300334.SZ, 成交量132，成交价13.54\n",
      "2020-02-13, 买入300402.SZ, 成交量99，成交价8.19\n",
      "2020-02-13, 卖出300553.SZ, 成交量-17，成交价35.75\n",
      "2020-03-26, 卖出300334.SZ, 成交量-1500，成交价15.58\n",
      "2020-03-26, 卖出300141.SZ, 成交量-674，成交价53.91\n",
      "2020-03-26, 买入300402.SZ, 成交量279，成交价8.51\n",
      "2020-03-26, 买入300277.SZ, 成交量556，成交价41.92\n",
      "2020-03-26, 买入300553.SZ, 成交量83，成交价36.29\n",
      "2020-03-26, 买入300228.SZ, 成交量937，成交价24.91\n",
      "2020-03-26, 买入300539.SZ, 成交量143，成交价15.57\n",
      "2020-05-13, 卖出300539.SZ, 成交量-1507，成交价14.79\n",
      "2020-05-13, 卖出300402.SZ, 成交量-2753，成交价8.50\n",
      "2020-05-13, 卖出300228.SZ, 成交量-937，成交价26.20\n",
      "2020-05-13, 卖出300553.SZ, 成交量-647，成交价34.19\n",
      "2020-05-13, 卖出300277.SZ, 成交量-556，成交价41.08\n",
      "2020-05-13, 买入300557.SZ, 成交量900，成交价25.99\n",
      "2020-05-13, 买入300330.SZ, 成交量1247，成交价19.05\n",
      "2020-05-13, 买入300592.SZ, 成交量2306，成交价10.27\n",
      "2020-05-13, 买入300588.SZ, 成交量1603，成交价14.89\n",
      "2020-05-13, 买入300152.SZ, 成交量1420，成交价16.46\n",
      "2020-06-24, 卖出300330.SZ, 成交量-1247，成交价22.60\n",
      "2020-06-24, 卖出300592.SZ, 成交量-2306，成交价12.88\n",
      "2020-06-24, 买入300153.SZ, 成交量1157，成交价22.44\n",
      "2020-06-24, 买入300105.SZ, 成交量1032，成交价25.32\n",
      "2020-06-24, 买入300588.SZ, 成交量121，成交价15.13\n",
      "2020-06-24, 买入300152.SZ, 成交量218，成交价15.91\n",
      "2020-06-24, 卖出300557.SZ, 成交量-20，成交价29.62\n",
      "2020-08-07, 卖出300588.SZ, 成交量-1724，成交价17.26\n",
      "2020-08-07, 卖出300557.SZ, 成交量-880，成交价36.22\n",
      "2020-08-07, 买入300153.SZ, 成交量52，成交价24.48\n",
      "2020-08-07, 买入300528.SZ, 成交量3308，成交价8.92\n",
      "2020-08-07, 买入300555.SZ, 成交量1266，成交价23.29\n",
      "2020-08-07, 买入300152.SZ, 成交量25，成交价17.63\n",
      "2020-08-07, 买入300105.SZ, 成交量14，成交价28.12\n",
      "2020-09-18, 卖出300153.SZ, 成交量-1209，成交价29.50\n",
      "2020-09-18, 卖出300152.SZ, 成交量-1663，成交价32.09\n",
      "2020-09-18, 卖出300105.SZ, 成交量-1046，成交价33.72\n",
      "2020-09-18, 卖出300555.SZ, 成交量-1266，成交价25.53\n",
      "2020-09-18, 卖出300528.SZ, 成交量-3308，成交价11.38\n",
      "2020-09-18, 买入300557.SZ, 成交量1189，成交价31.66\n",
      "2020-09-18, 买入300534.SZ, 成交量1503，成交价25.16\n",
      "2020-09-18, 买入300211.SZ, 成交量732，成交价50.71\n",
      "2020-09-18, 买入300442.SZ, 成交量1363，成交价27.35\n",
      "2020-09-18, 买入300282.SZ, 成交量1256，成交价30.02\n",
      "2020-11-09, 卖出300282.SZ, 成交量-1256，成交价25.49\n",
      "2020-11-09, 卖出300442.SZ, 成交量-1363，成交价32.18\n",
      "2020-11-09, 卖出300557.SZ, 成交量-1189，成交价37.50\n",
      "2020-11-09, 卖出300534.SZ, 成交量-1503，成交价28.50\n",
      "2020-11-09, 买入300254.SZ, 成交量3088，成交价12.94\n",
      "2020-11-09, 买入300211.SZ, 成交量5，成交价54.56\n",
      "2020-11-09, 买入300069.SZ, 成交量1199，成交价33.95\n",
      "2020-11-09, 买入300330.SZ, 成交量1529，成交价26.65\n",
      "2020-11-09, 买入300404.SZ, 成交量923，成交价43.40\n",
      "2020-12-21, 卖出300404.SZ, 成交量-923，成交价39.06\n",
      "2020-12-21, 买入300211.SZ, 成交量46，成交价41.98\n",
      "2020-12-21, 买入300254.SZ, 成交量160，成交价10.49\n",
      "2020-12-21, 买入300330.SZ, 成交量8，成交价22.23\n",
      "2020-12-21, 卖出300069.SZ, 成交量-10，成交价28.80\n",
      "2020-12-21, 买入300152.SZ, 成交量1634，成交价21.01\n",
      "2021-02-02, 卖出300152.SZ, 成交量-1634，成交价26.38\n",
      "2021-02-02, 卖出300211.SZ, 成交量-783，成交价55.79\n",
      "2021-02-02, 买入300330.SZ, 成交量361，成交价17.86\n",
      "2021-02-02, 买入300254.SZ, 成交量1074，成交价7.96\n",
      "2021-02-02, 买入300555.SZ, 成交量1833，成交价18.70\n",
      "2021-02-02, 买入300153.SZ, 成交量1534，成交价22.12\n",
      "2021-02-02, 买入300069.SZ, 成交量104，成交价26.16\n",
      "2021-03-23, 卖出300153.SZ, 成交量-1534，成交价25.26\n",
      "2021-03-23, 卖出300254.SZ, 成交量-142，成交价8.98\n",
      "2021-03-23, 买入300330.SZ, 成交量32，成交价19.46\n",
      "2021-03-23, 买入300539.SZ, 成交量2344，成交价15.97\n",
      "2021-03-23, 买入300069.SZ, 成交量18，成交价28.56\n",
      "2021-03-23, 卖出300555.SZ, 成交量-35，成交价20.92\n",
      "2021-05-10, 卖出300539.SZ, 成交量-2344，成交价15.77\n",
      "2021-05-10, 卖出300330.SZ, 成交量-1930，成交价18.77\n",
      "2021-05-10, 卖出300069.SZ, 成交量-1311，成交价26.14\n",
      "2021-05-10, 卖出300254.SZ, 成交量-4180，成交价10.22\n",
      "2021-05-10, 卖出300555.SZ, 成交量-1798，成交价22.25\n",
      "2021-05-10, 买入300557.SZ, 成交量1550，成交价24.33\n",
      "2021-05-10, 买入300105.SZ, 成交量1454，成交价26.13\n",
      "2021-05-10, 买入300807.SZ, 成交量1608，成交价23.41\n",
      "2021-05-10, 买入300076.SZ, 成交量1078，成交价34.99\n",
      "2021-05-10, 买入300688.SZ, 成交量1590，成交价23.73\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2021-06-22, 卖出300105.SZ, 成交量-1454，成交价31.78\n",
      "2021-06-22, 卖出300076.SZ, 成交量-1078，成交价62.92\n",
      "2021-06-22, 卖出300807.SZ, 成交量-1608，成交价27.65\n",
      "2021-06-22, 卖出300688.SZ, 成交量-1590，成交价27.37\n",
      "2021-06-22, 买入300534.SZ, 成交量2245，成交价21.29\n",
      "2021-06-22, 买入300557.SZ, 成交量188，成交价27.34\n",
      "2021-06-22, 买入300836.SZ, 成交量1311，成交价36.77\n",
      "2021-06-22, 买入300152.SZ, 成交量2047，成交价23.42\n",
      "2021-06-22, 买入300313.SZ, 成交量3397，成交价14.29\n",
      "2021-08-03, 卖出300836.SZ, 成交量-1311，成交价37.40\n",
      "2021-08-03, 卖出300152.SZ, 成交量-2047，成交价25.69\n",
      "2021-08-03, 卖出300534.SZ, 成交量-2245，成交价23.58\n",
      "2021-08-03, 买入300313.SZ, 成交量519，成交价12.47\n",
      "2021-08-03, 卖出300557.SZ, 成交量-43，成交价28.57\n",
      "2021-08-03, 买入300688.SZ, 成交量1989，成交价24.93\n",
      "2021-08-03, 买入300807.SZ, 成交量1871，成交价26.06\n",
      "2021-08-03, 买入300135.SZ, 成交量1442，成交价33.81\n",
      "2021-09-14, 卖出300557.SZ, 成交量-1695，成交价29.52\n",
      "2021-09-14, 卖出300807.SZ, 成交量-1871，成交价24.51\n",
      "2021-09-14, 卖出300688.SZ, 成交量-1989，成交价43.73\n",
      "2021-09-14, 卖出300313.SZ, 成交量-3916，成交价20.53\n",
      "2021-09-14, 卖出300135.SZ, 成交量-1442，成交价39.24\n",
      "2021-09-14, 买入300176.SZ, 成交量1952，成交价32.02\n",
      "2021-09-14, 买入300555.SZ, 成交量2787，成交价22.28\n",
      "2021-09-14, 买入300615.SZ, 成交量2030，成交价30.61\n",
      "2021-09-14, 买入300565.SZ, 成交量3540，成交价17.42\n",
      "2021-09-14, 买入300345.SZ, 成交量2623，成交价23.52\n",
      "2021-11-04, 卖出300565.SZ, 成交量-3540，成交价15.18\n",
      "2021-11-04, 卖出300176.SZ, 成交量-1952，成交价25.91\n",
      "2021-11-04, 卖出300615.SZ, 成交量-2030，成交价31.72\n",
      "2021-11-04, 卖出300345.SZ, 成交量-2623，成交价21.67\n",
      "2021-11-04, 买入300330.SZ, 成交量2903，成交价19.44\n",
      "2021-11-04, 买入300555.SZ, 成交量88，成交价19.88\n",
      "2021-11-04, 买入300836.SZ, 成交量1811，成交价31.45\n",
      "2021-11-04, 买入300086.SZ, 成交量2399，成交价23.73\n",
      "2021-11-04, 买入300534.SZ, 成交量2969，成交价19.18\n",
      "2021-12-16, 卖出300836.SZ, 成交量-1811，成交价37.13\n",
      "2021-12-16, 卖出300534.SZ, 成交量-2969，成交价21.64\n",
      "2021-12-16, 买入300330.SZ, 成交量157，成交价20.50\n",
      "2021-12-16, 买入300086.SZ, 成交量100，成交价25.15\n",
      "2021-12-16, 卖出300555.SZ, 成交量-137，成交价22.98\n",
      "2021-12-16, 买入300313.SZ, 成交量3392，成交价18.65\n",
      "2021-12-16, 买入300345.SZ, 成交量2733，成交价23.09\n",
      "2022-01-28, 卖出300086.SZ, 成交量-2499，成交价30.76\n",
      "2022-01-28, 卖出300555.SZ, 成交量-2738，成交价20.87\n",
      "2022-01-28, 买入300313.SZ, 成交量1207，成交价12.81\n",
      "2022-01-28, 卖出300330.SZ, 成交量-43，成交价19.68\n",
      "2022-01-28, 买入300345.SZ, 成交量126，成交价21.02\n",
      "2022-01-28, 买入300742.SZ, 成交量2036，成交价28.95\n",
      "2022-01-28, 买入300553.SZ, 成交量1678，成交价34.95\n",
      "2022-03-18, 卖出300553.SZ, 成交量-1678，成交价34.57\n",
      "2022-03-18, 卖出300330.SZ, 成交量-3017，成交价26.09\n",
      "2022-03-18, 卖出300742.SZ, 成交量-2036，成交价30.70\n",
      "2022-03-18, 买入300313.SZ, 成交量470，成交价12.71\n",
      "2022-03-18, 买入300836.SZ, 成交量2057，成交价31.17\n",
      "2022-03-18, 买入300555.SZ, 成交量3099，成交价20.56\n",
      "2022-03-18, 卖出300345.SZ, 成交量-61，成交价23.09\n",
      "2022-03-18, 买入300819.SZ, 成交量2943，成交价21.49\n",
      "2022-05-06, 卖出300836.SZ, 成交量-2057，成交价26.14\n",
      "2022-05-06, 卖出300819.SZ, 成交量-2943，成交价21.15\n",
      "2022-05-06, 卖出300555.SZ, 成交量-3099，成交价17.66\n",
      "2022-05-06, 卖出300313.SZ, 成交量-5069，成交价10.03\n",
      "2022-05-06, 卖出300345.SZ, 成交量-2798，成交价19.73\n",
      "2022-05-06, 买入300594.SZ, 成交量3882，成交价14.33\n",
      "2022-05-06, 买入300557.SZ, 成交量2289，成交价24.55\n",
      "2022-05-06, 买入300380.SZ, 成交量2096，成交价26.64\n",
      "2022-05-06, 买入300277.SZ, 成交量1776，成交价31.18\n",
      "2022-05-06, 买入300417.SZ, 成交量1754，成交价31.47\n",
      "2022-06-20, 卖出300380.SZ, 成交量-2096，成交价30.85\n",
      "2022-06-20, 卖出300277.SZ, 成交量-1776，成交价35.75\n",
      "2022-06-20, 卖出300417.SZ, 成交量-1754，成交价35.90\n",
      "2022-06-20, 买入300330.SZ, 成交量3207，成交价19.70\n",
      "2022-06-20, 卖出300557.SZ, 成交量-4，成交价27.56\n",
      "2022-06-20, 卖出300594.SZ, 成交量-60，成交价16.72\n",
      "2022-06-20, 买入300521.SZ, 成交量3172，成交价19.85\n",
      "2022-06-20, 买入300321.SZ, 成交量1842，成交价34.85\n",
      "2022-08-01, 卖出300521.SZ, 成交量-3172，成交价23.63\n",
      "2022-08-01, 卖出300557.SZ, 成交量-2285，成交价33.23\n",
      "2022-08-01, 卖出300594.SZ, 成交量-3822，成交价18.78\n",
      "2022-08-01, 买入300380.SZ, 成交量2345，成交价29.61\n",
      "2022-08-01, 买入300330.SZ, 成交量206，成交价20.15\n",
      "2022-08-01, 买入300321.SZ, 成交量75，成交价36.73\n",
      "2022-08-01, 买入300562.SZ, 成交量2182，成交价31.66\n",
      "2022-08-01, 买入300668.SZ, 成交量1460，成交价47.14\n",
      "2022-09-13, 卖出300668.SZ, 成交量-1460，成交价53.39\n",
      "2022-09-13, 卖出300330.SZ, 成交量-3413，成交价13.20\n",
      "2022-09-13, 卖出300380.SZ, 成交量-2345，成交价30.21\n",
      "2022-09-13, 卖出300562.SZ, 成交量-2182，成交价30.71\n",
      "2022-09-13, 买入300637.SZ, 成交量4418，成交价15.13\n",
      "2022-09-13, 卖出300321.SZ, 成交量-78，成交价36.67\n",
      "2022-09-13, 买入300399.SZ, 成交量2621，成交价25.58\n",
      "2022-09-13, 买入300126.SZ, 成交量2799，成交价23.92\n",
      "2022-09-13, 买入300446.SZ, 成交量1623，成交价41.18\n",
      "2022-11-01, 卖出300446.SZ, 成交量-1623，成交价32.89\n",
      "2022-11-01, 卖出300399.SZ, 成交量-2621，成交价25.60\n",
      "2022-11-01, 卖出300637.SZ, 成交量-4418，成交价13.90\n",
      "2022-11-01, 卖出300126.SZ, 成交量-2799，成交价22.13\n",
      "2022-11-01, 买入300321.SZ, 成交量50，成交价32.47\n",
      "2022-11-01, 买入300594.SZ, 成交量3883，成交价15.75\n",
      "2022-11-01, 买入300665.SZ, 成交量3409，成交价17.96\n",
      "2022-11-01, 买入300426.SZ, 成交量2177，成交价28.25\n",
      "2022-11-01, 买入300417.SZ, 成交量1623，成交价38.32\n",
      "2022-12-13, 卖出300426.SZ, 成交量-2177，成交价32.58\n",
      "2022-12-13, 卖出300594.SZ, 成交量-3883，成交价20.85\n",
      "2022-12-13, 卖出300417.SZ, 成交量-1623，成交价38.47\n",
      "2022-12-13, 买入300321.SZ, 成交量56，成交价34.74\n",
      "2022-12-13, 买入300665.SZ, 成交量280，成交价18.37\n",
      "2022-12-13, 买入300849.SZ, 成交量3631，成交价18.58\n",
      "2022-12-13, 买入300810.SZ, 成交量2510，成交价26.89\n",
      "2022-12-13, 买入300557.SZ, 成交量2105，成交价32.05\n",
      "2023-02-01, 卖出300849.SZ, 成交量-3631，成交价19.45\n",
      "2023-02-01, 买入300321.SZ, 成交量11，成交价35.42\n",
      "2023-02-01, 买入300665.SZ, 成交量166，成交价17.94\n",
      "2023-02-01, 买入300808.SZ, 成交量4937，成交价13.99\n",
      "2023-02-01, 卖出300810.SZ, 成交量-56，成交价28.19\n",
      "2023-02-01, 卖出300557.SZ, 成交量-100，成交价34.52\n",
      "最终资金: 400576.95\n",
      "夏普比率: OrderedDict([('sharperatio', 0.7650405903593316)])\n",
      "回撤指标: AutoOrderedDict([('len', 1), ('drawdown', 0.0192775723694062), ('moneydown', 77.23639999999432), ('max', AutoOrderedDict([('len', 261), ('drawdown', 31.96122857543127), ('moneydown', 100294.79056300002)]))])\n"
     ]
    }
   ],
   "source": [
    "start=datetime(2018,2,22)\n",
    "end=datetime(2023,2,10)\n",
    "cash_value={}\n",
    "result=huice_run_num(start,end,stock_list,my_strategy_date_2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f20f609c",
   "metadata": {},
   "outputs": [],
   "source": [
    "cw_columns={'每股营业总收入':[False,1],'营业收入环比增长率(%)(单季度)':[False,1]}\n",
    "\n",
    "cw_daily=cwzbsj[cwzbsj[\"公告日期\"]<time_id[i]].groupby(\"股票代码\").last()\n",
    "cw_list_tem_0=cw_daily[cw_daily[\"股票代码\"].isin(stock_list_tem)]\n",
    "for j in cw_columns.keys():\n",
    "    factor1_stock=cw_list_tem_0.sort_values(by=j,ascending=cw_columns[j][0])[\"股票代码\"].tolist()\n",
    "    f_1_df=f_1_df+pd.Series(range(1,len(factor1_stock)+1),index=factor1_stock)*cw_columns[j][1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "id": "cb0c21a7",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "公告日期\n",
      "2020-08-25   2020-08-25\n",
      "2020-08-25   2020-08-25\n",
      "2020-10-28   2020-10-28\n",
      "2020-08-25   2020-08-25\n",
      "2021-04-15   2021-04-15\n",
      "2020-08-25   2020-08-25\n",
      "2020-10-28   2020-10-28\n",
      "2021-04-08   2021-04-08\n",
      "2021-04-15   2021-04-15\n",
      "2021-08-27   2021-08-27\n",
      "2021-10-25   2021-10-25\n",
      "Name: 公告日期, dtype: datetime64[ns]\n"
     ]
    }
   ],
   "source": [
    "for i in cwzbsj[cwzbsj[\"公告日期\"]<time_id[1000]].groupby(\"股票代码\"):\n",
    "    print(i[1][\"公告日期\"])\n",
    "    break"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 118,
   "id": "59f0c8f6",
   "metadata": {},
   "outputs": [],
   "source": [
    "cwzbsj[\"报告期\"]=cwzbsj[\"报告期\"].astype(\"str\").astype(\"datetime64\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 115,
   "id": "11104221",
   "metadata": {},
   "outputs": [],
   "source": [
    "cwzbsj.set_index(\"公告日期\",inplace=True,drop=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 103,
   "id": "44b62565",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "index                           0\n",
       "股票代码                            0\n",
       "公告日期                            1\n",
       "报告期                             0\n",
       "基本每股收益                       2143\n",
       "                            ...  \n",
       "归属母公司股东的净利润同比增长率(%)(单季度)     7679\n",
       "归属母公司股东的净利润环比增长率(%)(单季度)     3810\n",
       "净资产同比增长率                     6967\n",
       "研发费用                        10375\n",
       "更新标识                            0\n",
       "Length: 168, dtype: int64"
      ]
     },
     "execution_count": 103,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cwzbsj.isnull().sum()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 126,
   "id": "a9c57aa9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0       2018-12-31\n",
       "1       2019-06-30\n",
       "2       2019-09-30\n",
       "3       2019-12-31\n",
       "4       2020-03-31\n",
       "           ...    \n",
       "61222   2021-09-30\n",
       "61223   2021-12-31\n",
       "61224   2022-03-31\n",
       "61225   2022-06-30\n",
       "61226   2022-09-30\n",
       "Name: 报告期, Length: 61227, dtype: datetime64[ns]"
      ]
     },
     "execution_count": 126,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cwzbsj[\"报告期\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 130,
   "id": "fb3baca7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array(['index', '股票代码', '公告日期', '报告期', '基本每股收益', '稀释每股收益', '每股营业总收入',\n",
       "       '每股营业收入', '每股资本公积', '每股盈余公积', '每股未分配利润', '非经常性损益',\n",
       "       '扣除非经常性损益后的净利润(扣非净利润)', '毛利', '流动比率', '速动比率', '保守速动比率', '存货周转天数',\n",
       "       '应收账款周转天数', '存货周转率', '应收账款周转率', '流动资产周转率', '固定资产周转率', '总资产周转率',\n",
       "       '经营活动净收益', '价值变动净收益', '利息费用', '折旧与摊销', '息税前利润', '息税折旧摊销前利润',\n",
       "       '企业自由现金流量', '股权自由现金流量', '无息流动负债', '无息非流动负债', '带息债务', '净债务', '有形资产',\n",
       "       '营运资金', '营运流动资本', '全部投入资本', '留存收益', '期末摊薄每股收益', '每股净资产',\n",
       "       '每股经营活动产生的现金流量净额', '每股留存收益', '每股现金流量净额', '每股息税前利润', '每股企业自由现金流量',\n",
       "       '每股股东自由现金流量', '销售净利率', '销售毛利率', '销售成本率', '销售期间费用率', '净利润/营业总收入',\n",
       "       '销售费用/营业总收入', '管理费用/营业总收入', '财务费用/营业总收入', '资产减值损失/营业总收入',\n",
       "       '营业总成本/营业总收入', '营业利润/营业总收入', '息税前利润/营业总收入', '净资产收益率', '加权平均净资产收益率',\n",
       "       '净资产收益率(扣除非经常损益)', '总资产报酬率', '总资产净利润', '投入资本回报率', '年化净资产收益率',\n",
       "       '年化总资产报酬率', '平均净资产收益率(增发条件)', '经营活动净收益/利润总额', '价值变动净收益/利润总额',\n",
       "       '营业外收支净额/利润总额', '所得税/利润总额', '扣除非经常损益后的净利润/净利润',\n",
       "       '销售商品提供劳务收到的现金/营业收入', '经营活动产生的现金流量净额/营业收入',\n",
       "       '经营活动产生的现金流量净额/经营活动净收益', '资本支出/折旧和摊销', '资产负债率', '权益乘数',\n",
       "       '权益乘数(杜邦分析)', '流动资产/总资产', '非流动资产/总资产', '有形资产/总资产', '带息债务/全部投入资本',\n",
       "       '归属于母公司的股东权益/全部投入资本', '流动负债/负债合计', '非流动负债/负债合计',\n",
       "       '经营活动产生的现金流量净额/流动负债', '产权比率', '归属于母公司的股东权益/负债合计',\n",
       "       '归属于母公司的股东权益/带息债务', '有形资产/负债合计', '有形资产/带息债务', '有形资产/净债务',\n",
       "       '经营活动产生的现金流量净额/负债合计', '经营活动产生的现金流量净额/带息债务', '经营活动产生的现金流量净额/净债务',\n",
       "       '已获利息倍数(EBIT/利息费用)', '长期债务与营运资金比率', '息税折旧摊销前利润/负债合计', '营业周期',\n",
       "       '年化总资产净利率', '总资产净利率(杜邦分析)', '固定资产合计', '扣除财务费用前营业利润', '非营业利润',\n",
       "       '营业利润/利润总额', '非营业利润/利润总额', '经营活动产生的现金流量净额/营业利润', '货币资金/流动负债',\n",
       "       '货币资金/带息流动负债', '营业利润/流动负债', '营业利润/负债合计', '年化投入资本回报率', '固定资产合计周转率',\n",
       "       '利润总额/营业收入', '经营活动单季度净收益', '价值变动单季度净收益', '扣除非经常损益后的单季度净利润',\n",
       "       '每股收益(单季度)', '销售净利率(单季度)', '销售毛利率(单季度)', '销售期间费用率(单季度)',\n",
       "       '净利润/营业总收入(单季度)', '销售费用/营业总收入 (单季度)', '管理费用/营业总收入 (单季度)',\n",
       "       '财务费用/营业总收入 (单季度)', '资产减值损失/营业总收入(单季度)', '营业总成本/营业总收入 (单季度)',\n",
       "       '营业利润/营业总收入(单季度)', '净资产收益率(单季度)', '净资产单季度收益率(扣除非经常损益)',\n",
       "       '总资产净利润(单季度)', '经营活动净收益/利润总额(单季度)', '价值变动净收益/利润总额(单季度)',\n",
       "       '扣除非经常损益后的净利润/净利润(单季度)', '销售商品提供劳务收到的现金/营业收入(单季度)',\n",
       "       '经营活动产生的现金流量净额/营业收入(单季度)', '经营活动产生的现金流量净额/经营活动净收益(单季度)',\n",
       "       '基本每股收益同比增长率(%)', '稀释每股收益同比增长率(%)', '每股经营活动产生的现金流量净额同比增长率(%)',\n",
       "       '营业利润同比增长率(%)', '利润总额同比增长率(%)', '归属母公司股东的净利润同比增长率(%)',\n",
       "       '归属母公司股东的净利润-扣除非经常损益同比增长率(%)', '经营活动产生的现金流量净额同比增长率(%)',\n",
       "       '净资产收益率(摊薄)同比增长率(%)', '每股净资产相对年初增长率(%)', '资产总计相对年初增长率(%)',\n",
       "       '归属母公司的股东权益相对年初增长率(%)', '营业总收入同比增长率(%)', '营业收入同比增长率(%)',\n",
       "       '营业总收入同比增长率(%)(单季度)', '营业总收入环比增长率(%)(单季度)', '营业收入同比增长率(%)(单季度)',\n",
       "       '营业收入环比增长率(%)(单季度)', '营业利润同比增长率(%)(单季度)', '营业利润环比增长率(%)(单季度)',\n",
       "       '净利润同比增长率(%)(单季度)', '净利润环比增长率(%)(单季度)', '归属母公司股东的净利润同比增长率(%)(单季度)',\n",
       "       '归属母公司股东的净利润环比增长率(%)(单季度)', '净资产同比增长率', '研发费用', '更新标识'],\n",
       "      dtype=object)"
      ]
     },
     "execution_count": 130,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cwzbsj.columns.values"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 127,
   "id": "6764867c",
   "metadata": {},
   "outputs": [],
   "source": [
    "z1=cwzbsj[(cwzbsj[\"报告期\"]<time_id[11])&(cwzbsj[\"报告期\"]>time_id[8])]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "3e4fa18d",
   "metadata": {},
   "outputs": [],
   "source": [
    "#cwzbsj[\"公告日期\"][85120:85150]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "48902cf7",
   "metadata": {},
   "source": [
    "### 基于行情因子或者财务因子的范围对股票池进行限定"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 88,
   "id": "88e3521d",
   "metadata": {},
   "outputs": [],
   "source": [
    "buy_date={}\n",
    "sell_date={}\n",
    "postion=set([])\n",
    "stock_list=set([])\n",
    "stock_columns={'总市值(万元)':[True,0.9],'市盈率(静态)':[False,1],'换手率(%)':[True,0.3]}\n",
    "cw_columns={}\n",
    "cw_compare={}\n",
    "#stock_columns={'总市值(万元)':[True,0.8],'市盈率(静态)':[False,1]}\n",
    "#cw_columns={'营业收入环比增长率(%)(单季度)':[True,0.4]}\n",
    "cw_compare={\"营业收入环比增长率(%)(单季度)\":[0.0,1000]}\n",
    "for i in range(0,len(time_id),30):\n",
    "    stock_list_tem=stock_daily[(stock_daily[\"date\"]==time_id[i+1])&(stock_daily[\"open\"]!=stock_daily[\"close\"])][\"股票代码\"].unique()\n",
    "    cw_list_tem_0=cwzbsj[(cwzbsj[\"公告日期\"]<time_id[i])&(cwzbsj[\"股票代码\"].isin(stock_list_tem))].groupby(\"股票代码\").last()\n",
    "\n",
    "    compare_0=cw_list_tem_0[\"index\"]>0\n",
    "    for k in cw_compare.keys():\n",
    "        compare_0=compare_0&(cw_list_tem_0[k]>cw_compare[k][0])\n",
    "        compare_0=compare_0&(cw_list_tem_0[k]<cw_compare[k][1])\n",
    "    cw_list_tem_1=cw_list_tem_0[compare_0]\n",
    "    stock_list_cw=cw_list_tem_1.index\n",
    "    \n",
    "    if len(stock_list_cw)>0:\n",
    "        stock_list_tem_0=stock_daily[(stock_daily[\"date\"]==time_id[i])&(stock_daily[\"股票代码\"].isin(stock_list_cw))]\n",
    "        columns_list=list(stock_columns.keys())\n",
    "        factor1_stock=stock_list_tem_0.sort_values(by=columns_list[0],ascending=stock_columns[columns_list[0]][0])[\"股票代码\"].tolist()\n",
    "        f_1_df=pd.Series(range(1,len(factor1_stock)+1),index=factor1_stock)*stock_columns[columns_list[0]][1]\n",
    "        for j in columns_list[1:]:\n",
    "            factor1_stock=stock_list_tem_0.sort_values(by=j,ascending=stock_columns[j][0])[\"股票代码\"].tolist()\n",
    "            f_1_df=f_1_df+pd.Series(range(1,len(factor1_stock)+1),index=factor1_stock)*stock_columns[j][1]\n",
    "    \n",
    "    \n",
    "    if len(cw_list_tem_1)>0:\n",
    "        for j in cw_columns.keys():\n",
    "            factor1_stock=cw_list_tem_1.sort_values(by=j,ascending=cw_columns[j][0]).index.tolist()\n",
    "            f_1_df=f_1_df+pd.Series(range(1,len(factor1_stock)+1),index=factor1_stock)*cw_columns[j][1]\n",
    "    \n",
    "    buy_list=f_1_df.sort_values().head(5).index.tolist()\n",
    "    buy_date.update({str(time_id[i].date()):buy_list})\n",
    "    sell_date.update({str(time_id[i].date()):list(postion-set(buy_list))})\n",
    "    postion=set(buy_list)\n",
    "    stock_list=stock_list|postion"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 89,
   "id": "6415aba2",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2018-02-22 2023-02-10\n",
      "初始资金: 100000.00\n",
      "2018-04-04, 买入300637.SZ, 成交量785，成交价25.20\n",
      "2018-04-04, 买入300405.SZ, 成交量805，成交价22.35\n",
      "2018-04-04, 买入300615.SZ, 成交量640，成交价28.00\n",
      "2018-04-04, 买入300126.SZ, 成交量746，成交价24.04\n",
      "2018-04-04, 买入300074.SZ, 成交量171，成交价104.30\n",
      "2018-05-22, 卖出300074.SZ, 成交量-171，成交价95.97\n",
      "2018-05-22, 卖出300615.SZ, 成交量-640，成交价34.80\n",
      "2018-05-22, 卖出300405.SZ, 成交量-805，成交价23.25\n",
      "2018-05-22, 卖出300637.SZ, 成交量-785，成交价24.12\n",
      "2018-05-22, 买入300126.SZ, 成交量52，成交价22.84\n",
      "2018-05-22, 买入300489.SZ, 成交量510，成交价36.05\n",
      "2018-05-22, 买入300235.SZ, 成交量383，成交价48.52\n",
      "2018-05-22, 买入300069.SZ, 成交量539，成交价34.15\n",
      "2018-05-22, 买入300254.SZ, 成交量1204，成交价15.38\n",
      "2018-07-04, 卖出300069.SZ, 成交量-539，成交价24.61\n",
      "2018-07-04, 卖出300254.SZ, 成交量-1204，成交价13.69\n",
      "2018-07-04, 卖出300126.SZ, 成交量-4，成交价19.02\n",
      "2018-07-04, 买入300268.SZ, 成交量528，成交价28.60\n",
      "2018-07-04, 买入300489.SZ, 成交量13，成交价28.86\n",
      "2018-07-04, 卖出300235.SZ, 成交量-1，成交价39.20\n",
      "2018-07-04, 买入300192.SZ, 成交量464，成交价31.98\n",
      "2018-08-15, 卖出300192.SZ, 成交量-464，成交价33.69\n",
      "2018-08-15, 卖出300235.SZ, 成交量-382，成交价36.99\n",
      "2018-08-15, 卖出300126.SZ, 成交量-49，成交价19.68\n",
      "2018-08-15, 买入300268.SZ, 成交量73，成交价24.16\n",
      "2018-08-15, 买入300239.SZ, 成交量642，成交价22.94\n",
      "2018-08-15, 买入300283.SZ, 成交量489，成交价30.08\n",
      "2018-09-27, 卖出300268.SZ, 成交量-601，成交价23.31\n",
      "2018-09-27, 卖出300239.SZ, 成交量-642，成交价22.62\n",
      "2018-09-27, 卖出300489.SZ, 成交量-523，成交价29.06\n",
      "2018-09-27, 买入300330.SZ, 成交量821，成交价17.31\n",
      "2018-09-27, 买入300126.SZ, 成交量22，成交价18.44\n",
      "2018-09-27, 买入300354.SZ, 成交量477，成交价29.75\n",
      "2018-09-27, 买入300030.SZ, 成交量583，成交价24.38\n",
      "2018-09-27, 买入300283.SZ, 成交量37，成交价26.88\n",
      "2018-11-15, 卖出300030.SZ, 成交量-583，成交价23.31\n",
      "2018-11-15, 卖出300354.SZ, 成交量-477，成交价29.23\n",
      "2018-11-15, 卖出300283.SZ, 成交量-526，成交价35.86\n",
      "2018-11-15, 卖出300126.SZ, 成交量-767，成交价20.99\n",
      "2018-11-15, 买入300330.SZ, 成交量61，成交价16.88\n",
      "2018-11-15, 买入300268.SZ, 成交量706，成交价21.16\n",
      "2018-11-15, 买入300293.SZ, 成交量418，成交价35.96\n",
      "2018-11-15, 买入300235.SZ, 成交量435，成交价34.31\n",
      "2018-11-15, 买入300551.SZ, 成交量799，成交价18.82\n",
      "2018-12-27, 卖出300551.SZ, 成交量-799，成交价21.10\n",
      "2018-12-27, 卖出300268.SZ, 成交量-47，成交价22.72\n",
      "2018-12-27, 买入300330.SZ, 成交量75，成交价15.43\n",
      "2018-12-27, 买入300293.SZ, 成交量18，成交价33.87\n",
      "2018-12-27, 买入300235.SZ, 成交量44，成交价31.18\n",
      "2018-12-27, 买入300277.SZ, 成交量443，成交价33.27\n",
      "2019-02-18, 卖出300277.SZ, 成交量-443，成交价33.32\n",
      "2019-02-18, 卖出300293.SZ, 成交量-436，成交价36.96\n",
      "2019-02-18, 买入300330.SZ, 成交量59，成交价15.49\n",
      "2019-02-18, 卖出300268.SZ, 成交量-70，成交价26.74\n",
      "2019-02-18, 买入300235.SZ, 成交量14，成交价32.02\n",
      "2019-02-18, 买入300460.SZ, 成交量1785，成交价8.88\n",
      "2019-02-18, 买入300126.SZ, 成交量810，成交价19.95\n",
      "2019-04-01, 卖出300126.SZ, 成交量-810，成交价24.94\n",
      "2019-04-01, 卖出300235.SZ, 成交量-493，成交价37.77\n",
      "2019-04-01, 卖出300460.SZ, 成交量-1785，成交价9.99\n",
      "2019-04-01, 买入300268.SZ, 成交量10，成交价31.24\n",
      "2019-04-01, 卖出300330.SZ, 成交量-100，成交价20.46\n",
      "2019-04-01, 买入300277.SZ, 成交量484，成交价38.69\n",
      "2019-04-01, 买入300105.SZ, 成交量644，成交价29.12\n",
      "2019-04-01, 买入300293.SZ, 成交量400，成交价47.16\n",
      "2019-05-17, 卖出300330.SZ, 成交量-916，成交价18.85\n",
      "2019-05-17, 卖出300105.SZ, 成交量-644，成交价27.16\n",
      "2019-05-17, 卖出300293.SZ, 成交量-400，成交价39.75\n",
      "2019-05-17, 卖出300268.SZ, 成交量-599，成交价30.71\n",
      "2019-05-17, 卖出300277.SZ, 成交量-484，成交价36.55\n",
      "2019-05-17, 买入300629.SZ, 成交量643，成交价26.90\n",
      "2019-05-17, 买入300636.SZ, 成交量923，成交价18.77\n",
      "2019-05-17, 买入300534.SZ, 成交量746，成交价23.12\n",
      "2019-05-17, 买入300235.SZ, 成交量480，成交价35.85\n",
      "2019-05-17, 买入300283.SZ, 成交量572，成交价30.26\n",
      "2019-07-01, 卖出300636.SZ, 成交量-923，成交价22.48\n",
      "2019-07-01, 卖出300629.SZ, 成交量-643，成交价36.23\n",
      "2019-07-01, 卖出300283.SZ, 成交量-572，成交价32.72\n",
      "2019-07-01, 买入300534.SZ, 成交量142，成交价22.31\n",
      "2019-07-01, 买入300235.SZ, 成交量27，成交价38.83\n",
      "2019-07-01, 买入300086.SZ, 成交量657，成交价29.71\n",
      "2019-07-01, 买入300281.SZ, 成交量529，成交价36.79\n",
      "2019-07-01, 买入300106.SZ, 成交量1674，成交价11.65\n",
      "2019-08-12, 卖出300106.SZ, 成交量-1674，成交价10.48\n",
      "2019-08-12, 卖出300534.SZ, 成交量-888，成交价19.39\n",
      "2019-08-12, 买入300086.SZ, 成交量66，成交价23.64\n",
      "2019-08-12, 买入300629.SZ, 成交量552，成交价31.06\n",
      "2019-08-12, 卖出300281.SZ, 成交量-12，成交价33.02\n",
      "2019-08-12, 卖出300235.SZ, 成交量-5，成交价34.05\n",
      "2019-08-12, 买入300240.SZ, 成交量788，成交价21.53\n",
      "2019-09-24, 卖出300086.SZ, 成交量-723，成交价25.11\n",
      "2019-09-24, 卖出300235.SZ, 成交量-502，成交价42.41\n",
      "2019-09-24, 卖出300240.SZ, 成交量-788，成交价23.41\n",
      "2019-09-24, 卖出300281.SZ, 成交量-517，成交价35.55\n",
      "2019-09-24, 卖出300629.SZ, 成交量-552，成交价31.58\n",
      "2019-09-24, 买入300092.SZ, 成交量1006，成交价18.45\n",
      "2019-09-24, 买入300489.SZ, 成交量478，成交价38.47\n",
      "2019-09-24, 买入300254.SZ, 成交量1502，成交价12.36\n",
      "2019-09-24, 买入300141.SZ, 成交量577，成交价31.93\n",
      "2019-09-24, 买入300105.SZ, 成交量669，成交价27.58\n",
      "2019-11-12, 卖出300141.SZ, 成交量-577，成交价29.63\n",
      "2019-11-12, 买入300489.SZ, 成交量10，成交价35.10\n",
      "2019-11-12, 卖出300092.SZ, 成交量-22，成交价17.55\n",
      "2019-11-12, 买入300254.SZ, 成交量2，成交价11.40\n",
      "2019-11-12, 买入300680.SZ, 成交量867，成交价19.65\n",
      "2019-11-12, 买入300105.SZ, 成交量29，成交价24.55\n",
      "2019-12-24, 卖出300680.SZ, 成交量-867，成交价21.96\n",
      "2019-12-24, 卖出300489.SZ, 成交量-17，成交价38.49\n",
      "2019-12-24, 买入300254.SZ, 成交量38，成交价11.67\n",
      "2019-12-24, 买入300092.SZ, 成交量9，成交价18.14\n",
      "2019-12-24, 买入300105.SZ, 成交量25，成交价25.15\n",
      "2019-12-24, 买入300062.SZ, 成交量813，成交价22.31\n",
      "2020-02-13, 卖出300062.SZ, 成交量-813，成交价20.92\n",
      "2020-02-13, 卖出300254.SZ, 成交量-1542，成交价13.31\n",
      "2020-02-13, 买入300092.SZ, 成交量121，成交价16.81\n",
      "2020-02-13, 买入300105.SZ, 成交量29，成交价24.85\n",
      "2020-02-13, 买入300022.SZ, 成交量1282，成交价14.68\n",
      "2020-02-13, 买入300680.SZ, 成交量916，成交价20.42\n",
      "2020-02-13, 卖出300489.SZ, 成交量-69，成交价47.08\n",
      "2020-03-26, 卖出300092.SZ, 成交量-1114，成交价19.55\n",
      "2020-03-26, 卖出300105.SZ, 成交量-752，成交价29.54\n",
      "2020-03-26, 卖出300489.SZ, 成交量-402，成交价74.22\n",
      "2020-03-26, 卖出300680.SZ, 成交量-916，成交价27.20\n",
      "2020-03-26, 买入300254.SZ, 成交量1951，成交价11.67\n",
      "2020-03-26, 买入300022.SZ, 成交量142，成交价16.09\n",
      "2020-03-26, 买入300518.SZ, 成交量1069，成交价21.31\n",
      "2020-03-26, 买入300211.SZ, 成交量486，成交价46.58\n",
      "2020-03-26, 买入300240.SZ, 成交量1129，成交价20.07\n",
      "2020-05-13, 卖出300022.SZ, 成交量-1424，成交价21.81\n",
      "2020-05-13, 卖出300518.SZ, 成交量-1069，成交价22.51\n",
      "2020-05-13, 卖出300254.SZ, 成交量-1951，成交价9.99\n",
      "2020-05-13, 卖出300240.SZ, 成交量-1129，成交价18.43\n",
      "2020-05-13, 卖出300211.SZ, 成交量-486，成交价46.52\n",
      "2020-05-13, 买入300400.SZ, 成交量594，成交价39.76\n",
      "2020-05-13, 买入300554.SZ, 成交量911，成交价25.80\n",
      "2020-05-13, 买入300293.SZ, 成交量541，成交价42.95\n",
      "2020-05-13, 买入300281.SZ, 成交量519，成交价44.89\n",
      "2020-05-13, 买入300191.SZ, 成交量336，成交价70.40\n",
      "2020-06-24, 买入300554.SZ, 成交量111，成交价27.03\n",
      "2020-06-24, 买入300400.SZ, 成交量81，成交价41.03\n",
      "2020-06-24, 买入300191.SZ, 成交量53，成交价71.24\n",
      "2020-06-24, 买入300281.SZ, 成交量66，成交价47.00\n",
      "2020-06-24, 卖出300293.SZ, 成交量-172，成交价73.72\n",
      "2020-08-07, 卖出300400.SZ, 成交量-675，成交价50.15\n",
      "2020-08-07, 卖出300281.SZ, 成交量-585，成交价47.18\n",
      "2020-08-07, 卖出300191.SZ, 成交量-389，成交价92.36\n",
      "2020-08-07, 卖出300293.SZ, 成交量-369，成交价111.36\n",
      "2020-08-07, 买入300710.SZ, 成交量1301，成交价28.80\n",
      "2020-08-07, 买入300220.SZ, 成交量267，成交价139.01\n",
      "2020-08-07, 买入300479.SZ, 成交量1077，成交价34.43\n",
      "2020-08-07, 买入300721.SZ, 成交量1513，成交价24.59\n",
      "2020-08-07, 卖出300554.SZ, 成交量-283，成交价46.80\n",
      "2020-09-18, 卖出300710.SZ, 成交量-1301，成交价33.20\n",
      "2020-09-18, 卖出300220.SZ, 成交量-267，成交价131.32\n",
      "2020-09-18, 卖出300554.SZ, 成交量-739，成交价39.09\n",
      "2020-09-18, 卖出300479.SZ, 成交量-1077，成交价34.75\n",
      "2020-09-18, 卖出300721.SZ, 成交量-1513，成交价34.44\n",
      "2020-09-18, 买入300557.SZ, 成交量1219，成交价31.66\n",
      "2020-09-18, 买入300211.SZ, 成交量751，成交价50.71\n",
      "2020-09-18, 买入300153.SZ, 成交量1290，成交价29.50\n",
      "2020-09-18, 买入300698.SZ, 成交量2123，成交价18.20\n",
      "2020-09-18, 买入300330.SZ, 成交量1405，成交价27.41\n",
      "2020-11-09, 卖出300153.SZ, 成交量-1290，成交价46.77\n",
      "2020-11-09, 卖出300330.SZ, 成交量-1405，成交价26.65\n",
      "2020-11-09, 卖出300698.SZ, 成交量-2123，成交价20.99\n",
      "2020-11-09, 卖出300557.SZ, 成交量-1219，成交价37.50\n",
      "2020-11-09, 卖出300211.SZ, 成交量-751，成交价54.56\n",
      "2020-11-09, 买入300528.SZ, 成交量5096，成交价8.81\n",
      "2020-11-09, 买入300592.SZ, 成交量2321，成交价19.15\n",
      "2020-11-09, 买入300521.SZ, 成交量1010，成交价45.02\n",
      "2020-11-09, 买入300105.SZ, 成交量1443，成交价31.42\n",
      "2020-11-09, 买入300289.SZ, 成交量2269，成交价19.79\n",
      "2020-12-21, 卖出300105.SZ, 成交量-1443，成交价27.93\n",
      "2020-12-21, 卖出300521.SZ, 成交量-1010，成交价42.40\n",
      "2020-12-21, 买入300528.SZ, 成交量38，成交价7.88\n",
      "2020-12-21, 买入300557.SZ, 成交量1387，成交价29.20\n",
      "2020-12-21, 买入300534.SZ, 成交量1755，成交价23.19\n",
      "2020-12-21, 卖出300592.SZ, 成交量-39，成交价17.92\n",
      "2020-12-21, 买入300289.SZ, 成交量262，成交价16.13\n",
      "2021-02-02, 卖出300289.SZ, 成交量-2531，成交价17.11\n",
      "2021-02-02, 卖出300592.SZ, 成交量-2282，成交价14.35\n",
      "2021-02-02, 卖出300534.SZ, 成交量-1755，成交价18.16\n",
      "2021-02-02, 卖出300528.SZ, 成交量-5134，成交价7.28\n",
      "2021-02-02, 买入300521.SZ, 成交量1179，成交价30.33\n",
      "2021-02-02, 买入300557.SZ, 成交量145，成交价23.41\n",
      "2021-02-02, 买入300105.SZ, 成交量1575，成交价22.96\n",
      "2021-02-02, 买入300588.SZ, 成交量3058，成交价11.60\n",
      "2021-02-02, 买入300282.SZ, 成交量2084，成交价17.12\n",
      "2021-03-23, 卖出300588.SZ, 成交量-3058，成交价12.89\n",
      "2021-03-23, 卖出300105.SZ, 成交量-1575，成交价30.36\n",
      "2021-03-23, 买入300698.SZ, 成交量2612，成交价15.22\n",
      "2021-03-23, 买入300521.SZ, 成交量160，成交价29.38\n",
      "2021-03-23, 卖出300557.SZ, 成交量-9，成交价26.22\n",
      "2021-03-23, 买入300282.SZ, 成交量71，成交价18.66\n",
      "2021-03-23, 买入300534.SZ, 成交量2012，成交价19.78\n",
      "2021-05-10, 卖出300698.SZ, 成交量-2612，成交价16.67\n",
      "2021-05-10, 卖出300557.SZ, 成交量-1523，成交价24.33\n",
      "2021-05-10, 卖出300282.SZ, 成交量-2155，成交价19.15\n",
      "2021-05-10, 卖出300521.SZ, 成交量-1339，成交价36.37\n",
      "2021-05-10, 卖出300534.SZ, 成交量-2012，成交价27.03\n",
      "2021-05-10, 买入300345.SZ, 成交量2643，成交价16.46\n",
      "2021-05-10, 买入300163.SZ, 成交量1960，成交价21.79\n",
      "2021-05-10, 买入300279.SZ, 成交量1453，成交价29.21\n",
      "2021-05-10, 买入300742.SZ, 成交量1976，成交价21.44\n",
      "2021-05-10, 买入300211.SZ, 成交量693，成交价61.40\n",
      "2021-06-22, 卖出300279.SZ, 成交量-1453，成交价40.76\n",
      "2021-06-22, 卖出300345.SZ, 成交量-2643，成交价24.56\n",
      "2021-06-22, 买入300106.SZ, 成交量3785，成交价14.34\n",
      "2021-06-22, 买入300742.SZ, 成交量159，成交价25.24\n",
      "2021-06-22, 买入300211.SZ, 成交量93，成交价68.84\n",
      "2021-06-22, 买入300126.SZ, 成交量1920，成交价28.37\n",
      "2021-06-22, 买入300163.SZ, 成交量327，成交价23.57\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2021-08-03, 卖出300106.SZ, 成交量-3785，成交价17.40\n",
      "2021-08-03, 卖出300211.SZ, 成交量-786，成交价92.66\n",
      "2021-08-03, 买入300345.SZ, 成交量2362，成交价26.41\n",
      "2021-08-03, 买入300819.SZ, 成交量2234，成交价27.88\n",
      "2021-08-03, 买入300163.SZ, 成交量236，成交价24.46\n",
      "2021-08-03, 买入300126.SZ, 成交量199，成交价29.69\n",
      "2021-08-03, 卖出300742.SZ, 成交量-21，成交价29.34\n",
      "2021-09-14, 卖出300742.SZ, 成交量-2114，成交价30.25\n",
      "2021-09-14, 卖出300819.SZ, 成交量-2234，成交价25.84\n",
      "2021-09-14, 卖出300345.SZ, 成交量-2362，成交价23.52\n",
      "2021-09-14, 卖出300163.SZ, 成交量-2523，成交价26.04\n",
      "2021-09-14, 卖出300126.SZ, 成交量-2119，成交价29.47\n",
      "2021-09-14, 买入300555.SZ, 成交量2735，成交价22.28\n",
      "2021-09-14, 买入300330.SZ, 成交量2725，成交价22.56\n",
      "2021-09-14, 买入300557.SZ, 成交量2073，成交价29.52\n",
      "2021-09-14, 买入300086.SZ, 成交量2334，成交价26.09\n",
      "2021-09-14, 买入300700.SZ, 成交量3291，成交价18.66\n",
      "2021-11-04, 卖出300330.SZ, 成交量-2725，成交价19.44\n",
      "2021-11-04, 卖出300086.SZ, 成交量-2334，成交价23.73\n",
      "2021-11-04, 卖出300555.SZ, 成交量-2735，成交价19.88\n",
      "2021-11-04, 买入300534.SZ, 成交量2836，成交价19.18\n",
      "2021-11-04, 卖出300700.SZ, 成交量-10，成交价16.40\n",
      "2021-11-04, 买入300279.SZ, 成交量1621，成交价33.60\n",
      "2021-11-04, 买入300176.SZ, 成交量2096，成交价25.91\n",
      "2021-11-04, 卖出300557.SZ, 成交量-10，成交价26.31\n",
      "2021-12-16, 卖出300279.SZ, 成交量-1621，成交价39.55\n",
      "2021-12-16, 买入300700.SZ, 成交量83，成交价18.31\n",
      "2021-12-16, 卖出300534.SZ, 成交量-25，成交价21.64\n",
      "2021-12-16, 买入300615.SZ, 成交量1993，成交价30.71\n",
      "2021-12-16, 卖出300557.SZ, 成交量-17，成交价30.54\n",
      "2021-12-16, 卖出300176.SZ, 成交量-68，成交价30.19\n",
      "2022-01-28, 卖出300534.SZ, 成交量-2811，成交价36.70\n",
      "2022-01-28, 卖出300700.SZ, 成交量-3364，成交价23.03\n",
      "2022-01-28, 买入300557.SZ, 成交量400，成交价28.23\n",
      "2022-01-28, 买入300615.SZ, 成交量565，成交价27.13\n",
      "2022-01-28, 买入300176.SZ, 成交量557，成交价26.82\n",
      "2022-01-28, 买入300321.SZ, 成交量1779，成交价39.28\n",
      "2022-01-28, 买入300106.SZ, 成交量4821，成交价14.47\n",
      "2022-03-18, 卖出300557.SZ, 成交量-2446，成交价33.54\n",
      "2022-03-18, 买入300615.SZ, 成交量102，成交价25.74\n",
      "2022-03-18, 买入300176.SZ, 成交量179，成交价24.86\n",
      "2022-03-18, 买入300076.SZ, 成交量1646，成交价42.23\n",
      "2022-03-18, 买入300321.SZ, 成交量12，成交价38.28\n",
      "2022-03-18, 买入300106.SZ, 成交量2，成交价14.26\n",
      "2022-05-06, 卖出300076.SZ, 成交量-1646，成交价33.25\n",
      "2022-05-06, 卖出300321.SZ, 成交量-1791，成交价30.47\n",
      "2022-05-06, 卖出300176.SZ, 成交量-2764，成交价19.52\n",
      "2022-05-06, 卖出300615.SZ, 成交量-2660，成交价22.31\n",
      "2022-05-06, 卖出300106.SZ, 成交量-4823，成交价12.35\n",
      "2022-05-06, 买入300126.SZ, 成交量2889，成交价19.77\n",
      "2022-05-06, 买入300489.SZ, 成交量1421，成交价40.12\n",
      "2022-05-06, 买入300446.SZ, 成交量1406，成交价40.28\n",
      "2022-05-06, 买入300756.SZ, 成交量1282，成交价44.98\n",
      "2022-05-06, 买入300545.SZ, 成交量2054，成交价27.84\n",
      "2022-06-20, 卖出300545.SZ, 成交量-2054，成交价33.96\n",
      "2022-06-20, 买入300126.SZ, 成交量55，成交价21.91\n",
      "2022-06-20, 卖出300489.SZ, 成交量-76，成交价48.16\n",
      "2022-06-20, 买入300446.SZ, 成交量104，成交价42.81\n",
      "2022-06-20, 买入300756.SZ, 成交量3，成交价50.38\n",
      "2022-06-20, 买入300289.SZ, 成交量4070，成交价15.92\n",
      "2022-08-01, 卖出300289.SZ, 成交量-4070，成交价16.23\n",
      "2022-08-01, 买入300446.SZ, 成交量134，成交价40.62\n",
      "2022-08-01, 买入300489.SZ, 成交量4，成交价49.94\n",
      "2022-08-01, 卖出300126.SZ, 成交量-310，成交价26.05\n",
      "2022-08-01, 卖出300756.SZ, 成交量-27，成交价53.05\n",
      "2022-08-01, 买入300640.SZ, 成交量3791，成交价17.71\n",
      "2022-09-13, 卖出300489.SZ, 成交量-1349，成交价49.76\n",
      "2022-09-13, 卖出300446.SZ, 成交量-1644，成交价41.18\n",
      "2022-09-13, 卖出300640.SZ, 成交量-3791，成交价17.91\n",
      "2022-09-13, 卖出300756.SZ, 成交量-1258，成交价48.00\n",
      "2022-09-13, 卖出300126.SZ, 成交量-2634，成交价23.92\n",
      "2022-09-13, 买入300321.SZ, 成交量1792，成交价36.67\n",
      "2022-09-13, 买入300594.SZ, 成交量3872，成交价16.92\n",
      "2022-09-13, 买入300779.SZ, 成交量4081，成交价16.13\n",
      "2022-09-13, 买入300562.SZ, 成交量2125，成交价30.71\n",
      "2022-09-13, 买入300521.SZ, 成交量3194，成交价20.56\n",
      "2022-11-01, 卖出300562.SZ, 成交量-2125，成交价31.00\n",
      "2022-11-01, 卖出300321.SZ, 成交量-1792，成交价32.47\n",
      "2022-11-01, 卖出300594.SZ, 成交量-3872，成交价15.75\n",
      "2022-11-01, 买入300637.SZ, 成交量4440，成交价13.90\n",
      "2022-11-01, 买入300736.SZ, 成交量2202，成交价28.29\n",
      "2022-11-01, 卖出300779.SZ, 成交量-47，成交价15.62\n",
      "2022-11-01, 卖出300521.SZ, 成交量-19，成交价19.45\n",
      "2022-11-01, 买入300126.SZ, 成交量2784，成交价22.13\n",
      "2022-12-13, 卖出300736.SZ, 成交量-2202，成交价37.85\n",
      "2022-12-13, 卖出300779.SZ, 成交量-4034，成交价35.92\n",
      "2022-12-13, 买入300637.SZ, 成交量1223，成交价14.32\n",
      "2022-12-13, 买入300126.SZ, 成交量778，成交价22.52\n",
      "2022-12-13, 买入300399.SZ, 成交量3050，成交价26.52\n",
      "2022-12-13, 买入300521.SZ, 成交量1084，成交价18.90\n",
      "2022-12-13, 买入300446.SZ, 成交量2218，成交价36.60\n",
      "2023-02-01, 卖出300399.SZ, 成交量-3050，成交价28.61\n",
      "2023-02-01, 卖出300521.SZ, 成交量-4259，成交价23.74\n",
      "2023-02-01, 买入300637.SZ, 成交量467，成交价14.02\n",
      "2023-02-01, 买入300405.SZ, 成交量3993，成交价21.64\n",
      "2023-02-01, 买入300478.SZ, 成交量4513，成交价19.19\n",
      "2023-02-01, 买入300446.SZ, 成交量70，成交价37.92\n",
      "2023-02-01, 买入300126.SZ, 成交量33，成交价24.07\n",
      "最终资金: 508270.44\n",
      "夏普比率: OrderedDict([('sharperatio', 0.8125671760797589)])\n",
      "回撤指标: AutoOrderedDict([('len', 1), ('drawdown', 0.30291820056352387), ('moneydown', 1544.3217000000295), ('max', AutoOrderedDict([('len', 217), ('drawdown', 36.10749319855399), ('moneydown', 132217.35329279985)]))])\n"
     ]
    }
   ],
   "source": [
    "start=datetime(2018,2,22)\n",
    "end=datetime(2023,2,10)\n",
    "cash_value={}\n",
    "result=huice_run_num(start,end,stock_list,my_strategy_date_2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "id": "10cb7a40",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "股票代码\n",
       "003001.SZ    False\n",
       "003002.SZ     True\n",
       "003003.SZ    False\n",
       "003004.SZ     True\n",
       "003005.SZ     True\n",
       "             ...  \n",
       "873169.BJ     True\n",
       "873223.BJ     True\n",
       "873305.BJ     True\n",
       "873339.BJ     True\n",
       "873527.BJ     True\n",
       "Length: 3705, dtype: bool"
      ]
     },
     "execution_count": 58,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "(cw_list_tem_0[\"index\"]>0)&(cw_list_tem_0[i]>c1[i][0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 87,
   "id": "73dad94e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "count    1253.000000\n",
       "mean        9.151285\n",
       "std        67.599922\n",
       "min       -90.184600\n",
       "25%       -13.154000\n",
       "50%         1.320600\n",
       "75%        17.198400\n",
       "max      1439.945700\n",
       "Name: 营业收入环比增长率(%)(单季度), dtype: float64"
      ]
     },
     "execution_count": 87,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cw_list_tem_0[\"营业收入环比增长率(%)(单季度)\"].describe()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "id": "2d7509f5",
   "metadata": {},
   "outputs": [],
   "source": [
    "c1={\"每股未分配利润\":[0.7,1.8],\"总资产净利率(杜邦分析)\":[0.7,2.8]}\n",
    "\n",
    "compare_0=cw_list_tem_0[\"index\"]>0\n",
    "for i in c1.keys():\n",
    "    compare_0=compare_0&(cw_list_tem_0[i]>c1[i][0])\n",
    "    compare_0=compare_0&(cw_list_tem_0[i]<c1[i][1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "id": "453dcc20",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['003015.SZ', '003037.SZ', '003816.SZ', '300017.SZ', '300020.SZ',\n",
       "       '300040.SZ', '300055.SZ', '300057.SZ', '300067.SZ', '300079.SZ',\n",
       "       ...\n",
       "       '688590.SH', '688600.SH', '688609.SH', '688659.SH', '831370.BJ',\n",
       "       '831832.BJ', '832145.BJ', '835985.BJ', '837344.BJ', '838030.BJ'],\n",
       "      dtype='object', name='股票代码', length=307)"
      ]
     },
     "execution_count": 63,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cw_list_tem_0[compare_0].index"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "abfe468b",
   "metadata": {},
   "outputs": [],
   "source": [
    "cw_list_tem_0=cwzbsj.groupby(\"股票代码\").last()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "id": "f56dac87",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "count    3704.000000\n",
       "mean        3.402587\n",
       "std        18.925910\n",
       "min      -309.143000\n",
       "25%         0.703825\n",
       "50%         2.872350\n",
       "75%         5.784450\n",
       "max      1040.782000\n",
       "Name: 总资产净利率(杜邦分析), dtype: float64"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "e941f7b9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "股票代码\n",
       "003001.SZ    False\n",
       "003002.SZ    False\n",
       "003003.SZ    False\n",
       "003004.SZ    False\n",
       "003005.SZ    False\n",
       "             ...  \n",
       "873169.BJ    False\n",
       "873223.BJ    False\n",
       "873305.BJ    False\n",
       "873339.BJ    False\n",
       "873527.BJ    False\n",
       "Name: 每股未分配利润, Length: 3705, dtype: bool"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "(cw_list_tem_0[\"每股未分配利润\"]>20)&(cw_list_tem_0[\"每股未分配利润\"]<120)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "bfd9443e",
   "metadata": {},
   "source": [
    "## 新策略框架的产品化\n",
    "\n",
    "### backtrader策略框架的封装——传参问题"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5bfed1fe",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "db3d6c44",
   "metadata": {},
   "source": [
    "### streamlit的变量共享与不同页面的函数互相调用"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c179c2e6",
   "metadata": {},
   "outputs": [],
   "source": [
    "import main_celue\n",
    "import sys\n",
    "sys.path.append(r'F:\\notebooks1\\streamlit\\streamlit-pages4-celue')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "656597cc",
   "metadata": {},
   "source": [
    "### 新多因子策略的表单调参"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6460060b",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "f0d4a0f8",
   "metadata": {},
   "source": [
    "### 引入财务数据的多因子策略的调参"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "47c665c5",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {
    "height": "calc(100% - 180px)",
    "left": "10px",
    "top": "150px",
    "width": "165px"
   },
   "toc_section_display": true,
   "toc_window_display": true
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
